#include<bits/stdc++.h>#define maxn 100010usingnamespace std;struct node{int val, dis;booloperator<(const node &x)const{return x.dis < dis;}};
priority_queue <node> q;struct Edge{int to, next, len;}edge[maxn <<1];int num, head[maxn], dis[maxn], vis[maxn], n, m, k;inlineintread(){int s =0, w =1;char c =getchar();for(;!isdigit(c); c =getchar())if(c =='-') w =-1;for(;isdigit(c); c =getchar()) s =(s <<1)+(s <<3)+(c ^48);return s * w;}voidaddedge(int x,int y,int z){ edge[++num]=(Edge){y, head[x], z}, head[x]= num;}intmain(){
n =read(), m =read(), k =read();for(int i =1; i <= m;++i){int x =read(), y =read(), z =read();for(int j =0; j <= k;++j){addedge(j * n + x, j * n + y, z),addedge(j * n + y, j * n + x, z);addedge(j * n + x,(j +1)* n + y, z >>1),addedge(j * n + y,(j +1)* n + x, z >>1);}}for(int i =0; i <= k;++i)addedge((i +1)* n,(i +2)* n,0);for(int i =2; i <= n *(k +1);++i) dis[i]=1e9;
q.push((node){1,0});while(!q.empty()){
node tmp = q.top(); q.pop();int u = tmp.val;if(vis[u])continue;
vis[u]=1;for(int i = head[u]; i; i = edge[i].next){int v = edge[i].to;if(dis[v]> dis[u]+ edge[i].len){
dis[v]= dis[u]+ edge[i].len;if(!vis[v]) q.push((node){v, dis[v]});}}}printf("%d\n", dis[n *(k +1)]);return0;}