#include<bits/stdc++.h>
#define maxn 800010
#define ll long long
using namespace std;
struct Edge
{
int be,next,u,v;
}e[maxn];
int tot;
int head[maxn];
void add(int x,int y,int z)
{
e[++tot].next=head[x];
e[tot].u=y;
e[tot].v=z;
e[tot].be=x;
head[x]=tot;
}
int f[maxn];
bool vis[maxn];
struct point
{
int dis,num;
};
inline bool operator < (point x,point y)
{
return x.dis < y.dis;
}
priority_queue<point> q;
int dis[maxn];
int main()
{
freopen("race.in","r",stdin);
freopen("race.out","w",stdout);
int n,m,k;
cin>>n>>m>>k;
for (int i=1;i<=m;i++)
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
add(a,b,c);
add(b,a,c);
for (int j=2;j<=k+1;j++)
{
add(a+(j-2)*n,b+(j-1)*n,c/2);
add(b+(j-2)*n,a+(j-1)*n,c/2);
}
}
point dian;
dian.num=1;
dian.dis=0;
q.push(dian);
vis[1]=true;
while(!q.empty())
{
point now=q.top();
q.pop();
for (int i=head[now.num];i;i=e[i].next)
{
int to=e[i].u;
if (!vis[to])
{
f[to]=f[now.num]+e[i].v;
point ha;
ha.num=to;
ha.dis=f[to];
q.push(ha);
vis[to]=1;
}
if (f[to]>f[now.num]+e[i].v)
{
f[to]=f[now.num]+e[i].v;
point ha;
ha.num=to;
ha.dis=f[to];
q.push(ha);
}
}
//cout<<endl;
}
int ans=23984693;
for (int i=n;i<=(k+1)*n;i+=n)
ans=min(ans,f[i]);
cout<<ans;
return 0;
}
/*
4 4 1
1 2 4
4 2 6
1 3 8
3 4 8
*/