#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
using namespace std;
const int N=10007,inf=0x7f7f7f7f;
int read(){
int ans=0,f=1,c=getchar();
while(c<‘0‘||c>‘9‘){if(c==‘-‘) f=-1; c=getchar();}
while(c>=‘0‘&&c<=‘9‘){ans=ans*10+(c-‘0‘); c=getchar();}
return ans*f;
}
int n,m,k;
int d[N][25];
struct node{
int d,h,pos;
bool operator <(const node& x)const{return x.d<d;}
};
priority_queue<node>q;
int first[N],cnt;
struct pos{int to,next,w;}e[10*N];
void ins(int a,int b,int w){e[++cnt]=(pos){b,first[a],w}; first[a]=cnt;}
void insert(int a,int b,int w){ins(a,b,w); ins(b,a,w);}
int dj(){
memset(d,0x7f,sizeof(d));
for(int i=0;i<=k;i++) d[1][i]=0;
q.push((node){0,0,1});
while(!q.empty()){
node p=q.top(); q.pop();
if(d[p.pos][p.h]!=p.d) continue;
if(p.pos==n) return p.d;
int x=p.pos,h=p.h;
for(int i=first[x];i;i=e[i].next){
int now=e[i].to;
if(d[now][h]>d[x][h]+e[i].w) d[now][h]=d[x][h]+e[i].w,q.push((node){d[now][h],h,now});
if(h<k&&d[now][h+1]>d[x][h]) d[now][h+1]=d[x][h],q.push((node){d[now][h+1],h+1,now});
}
}
return d[n][k];
}
int main()
{
int x,y,v;
n=read(); m=read(); k=read();
for(int i=1;i<=m;i++) x=read(),y=read(),v=read(),insert(x,y,v);
printf("%d\n",dj());
return 0;
}