#include<bits/stdc++.h>
using namespace std;
int n,m,k,s,t;
int head[5000005],dis[5000005],vis[5000005],num_edge;
struct node
{
int to,w,next;
}edge[5000005];
void add_edge(int from, int to, int w)
{
edge[++num_edge].next=head[from];
edge[num_edge].to=to;
edge[num_edge].w=w;
head[from]=num_edge;
}
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > Q;
void dijkstra(int s)
{
memset(dis,0x3f,sizeof(dis));
dis[s]=0;
Q.push(make_pair(0,s));
while(!Q.empty())
{
int u=Q.top().second;
Q.pop();
if(!vis[u])
{
vis[u]=1;
for(int i=head[u];i;i=edge[i].next)
{
int to=edge[i].to;
if(dis[to]>dis[u]+edge[i].w)
{
dis[to]=dis[u]+edge[i].w;
Q.push(make_pair(dis[to],to));
}
}
}
}
}
int main ()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m>>k>>s>>t;
for (int i=1;i<=m;i++)
{
int u,v,w;
cin>>u>>v>>w;
add_edge(u,v,w);
add_edge(v,u,w);
for (int j=1;j<=k;j++)
{
add_edge(u+(j-1)*n,v+j*n,0);
add_edge(u+j*n,v+j*n,w);
add_edge(v+j*n,u+j*n,w);
}
}
for(int i=1;i<=k;i++)
{
add_edge(t+(i-1)*n,t+i*n,0);
}
dijkstra(s);
cout<<dis[t+k*n];
return 0;
}