#include<iostream>#include<algorithm>#include<cstring>#include<cctype>#include<queue>usingnamespace std;using P = pair<int,int>;inlineintread(){int x =0;char ch =getchar();while(!isdigit(ch)){ch =getchar();}while(isdigit(ch)){
x =(x <<1)+(x <<3)+(ch ^48);
ch =getchar();}return x;}constint N =1e6+10;constint M =3e6+10;int n, m, k, tot, s, t;int head[N], dis[N], vis[N];struct edge{int to, nxt, w;}e[M];inlinevoidadd(int u,int v,int w){
e[tot]={v, head[u], w};
head[u]= tot++;}voiddij(int start){memset(dis,0x3f,sizeof dis);
priority_queue<P, vector<P>, greater<P>> que;
dis[start]=0;
que.push(make_pair(0, start));while(!que.empty()){int u = que.top().second;
que.pop();if(vis[u])continue;
vis[u]=1;for(int i = head[u];~i; i = e[i].nxt){int v = e[i].to, w = e[i].w;if(dis[v]> dis[u]+ w){
dis[v]= dis[u]+ w;
que.push(make_pair(dis[v], v));}}}}intmain(){memset(head,-1,sizeof head);
n =read(), m =read(), k =read();
s =read(), t =read();for(int i =0, u, v, val; i < m;++i){
u =read(), v =read(), val =read();add(u, v, val),add(v, u, val);for(int j =1; j <= k;++j){add(u + n*(j -1), v + n*j,0);add(v + n*(j -1), u + n*j,0);add(u + n*j, v + n*j, val);add(v +n*j, u + n*j, val);}}for(int i =1; i <= k;++i){add(t +(i -1)*n, t + i*n,0);}dij(s);printf("%d\n", dis[n*k + t]);return0;}