#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>
#define M 100009
using namespace std;
typedef long long ll;
struct pp{
ll data;
int pos;
pp(){}
pp(ll a,int b){
data=a; pos=b;
}
bool operator<(const pp &q)const{
return data > q.data;
}
};
vector<pp> v[M];
priority_queue<pp> q;
int n,m,k,chk[M];
ll d[M][13];
int main(){
int i,j;
scanf("%d %d %d",&n,&m,&k);
for (i=1;i<=m;i++){
int a,b;
ll c;
scanf("%d %d %lld",&a,&b,&c);
v[a].push_back(pp(c,b)); v[b].push_back(pp(c,a));
}
for (i=1;i<=n;i++) for (j=1;j<=k+1;j++) d[i][j]=-1;
d[1][1]=0;
q.push(pp(0,1));
while(!q.empty()){
pp now=q.top(); q.pop();
if (d[now.pos][k] < now.data && d[now.pos][k]!=-1) continue;
// if (d[now.pos][k]!=-1) chk[now.pos]=1;
for (auto there:v[now.pos]){
// if (chk[there.pos]) continue;
for (j=1;j<=k+1;j++)
if (d[there.pos][j]==-1) break;
d[there.pos][j]=now.data+there.data;
while(j>1 && d[there.pos][j] < d[there.pos][j-1]) swap(d[there.pos][j],d[there.pos][j-1]),j--;
d[there.pos][k+1]=-1;
if (j<=k) q.push(pp(now.data+there.data,there.pos));
}
}
printf("%lld",d[n][k]);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxxdWV1ZT4KI2RlZmluZSBNIDEwMDAwOQp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCnR5cGVkZWYgbG9uZyBsb25nIGxsOwpzdHJ1Y3QgcHB7CiAgICBsbCBkYXRhOwogICAgaW50IHBvczsKICAgIHBwKCl7fQogICAgcHAobGwgYSxpbnQgYil7CiAgICAgICAgZGF0YT1hOyBwb3M9YjsKICAgIH0KICAgIGJvb2wgb3BlcmF0b3I8KGNvbnN0IHBwICZxKWNvbnN0ewogICAgICAgIHJldHVybiBkYXRhID4gcS5kYXRhOwogICAgfQp9Owp2ZWN0b3I8cHA+IHZbTV07CnByaW9yaXR5X3F1ZXVlPHBwPiBxOwppbnQgbixtLGssY2hrW01dOwpsbCBkW01dWzEzXTsKaW50IG1haW4oKXsKICAgIGludCBpLGo7CiAgICBzY2FuZigiJWQgJWQgJWQiLCZuLCZtLCZrKTsKICAgIGZvciAoaT0xO2k8PW07aSsrKXsKICAgICAgICBpbnQgYSxiOwogICAgICAgIGxsIGM7CiAgICAgICAgc2NhbmYoIiVkICVkICVsbGQiLCZhLCZiLCZjKTsKICAgICAgICB2W2FdLnB1c2hfYmFjayhwcChjLGIpKTsgdltiXS5wdXNoX2JhY2socHAoYyxhKSk7CiAgICB9CiAgICAgCiAgICBmb3IgKGk9MTtpPD1uO2krKykgZm9yIChqPTE7ajw9aysxO2orKykgZFtpXVtqXT0tMTsKICAgIGRbMV1bMV09MDsKICAgIHEucHVzaChwcCgwLDEpKTsKICAgIHdoaWxlKCFxLmVtcHR5KCkpewogICAgICAgIHBwIG5vdz1xLnRvcCgpOyBxLnBvcCgpOwogICAgICAgICAKICAgICAgICBpZiAoZFtub3cucG9zXVtrXSA8IG5vdy5kYXRhICYmIGRbbm93LnBvc11ba10hPS0xKSBjb250aW51ZTsKICAgICAgICAgCi8vICAgICAgICBpZiAoZFtub3cucG9zXVtrXSE9LTEpIGNoa1tub3cucG9zXT0xOwogICAgICAgICAKICAgICAgICBmb3IgKGF1dG8gdGhlcmU6dltub3cucG9zXSl7Ci8vICAgICAgICAgICAgaWYgKGNoa1t0aGVyZS5wb3NdKSBjb250aW51ZTsKICAgICAgICAgICAgZm9yIChqPTE7ajw9aysxO2orKykKICAgICAgICAgICAgICAgIGlmIChkW3RoZXJlLnBvc11bal09PS0xKSBicmVhazsKICAgICAgICAgICAgZFt0aGVyZS5wb3NdW2pdPW5vdy5kYXRhK3RoZXJlLmRhdGE7CiAgICAgICAgICAgIHdoaWxlKGo+MSAmJiBkW3RoZXJlLnBvc11bal0gPCBkW3RoZXJlLnBvc11bai0xXSkgc3dhcChkW3RoZXJlLnBvc11bal0sZFt0aGVyZS5wb3NdW2otMV0pLGotLTsKICAgICAgICAgICAgZFt0aGVyZS5wb3NdW2srMV09LTE7CiAgICAgICAgICAgIGlmIChqPD1rKSBxLnB1c2gocHAobm93LmRhdGErdGhlcmUuZGF0YSx0aGVyZS5wb3MpKTsKICAgICAgICB9CiAgICB9CiAgICBwcmludGYoIiVsbGQiLGRbbl1ba10pOwp9