#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
struct node{
int to,next,w;
}tu[50010*201];
int head[50010*201];
int n,m,cnt,k;
void edge(int u,int v,int w){
cnt++;
tu[cnt].to=v;
tu[cnt].w=w;
tu[cnt].next=head[u];
head[u]=cnt;
}
struct edg{
int ans,id;
bool operator<(const edg &x)const{
return x.ans<ans;
}
};
priority_queue<edg> q;
int dis[50010*201],pre[50010*201];
bool inq[50010*201];
void init(int s){
for(int i=1;i<=n*(k+2);i++){
dis[i]=0x7fffffff;
}
// memset(dis,0x3f3f3f3f,sizeof(dis));
dis[s]=0;
}
void dij(int s){
init(s);
q.push((edg){0,s});
while(!q.empty()){
edg hd=q.top();
q.pop();
int x,y;
x=hd.id;y=hd.ans;
if(inq[x]==1) continue;
else inq[x]=1;
for(int i=head[x];i;i=tu[i].next){
int j=tu[i].to;
if(dis[j]>dis[x]+tu[i].w){
dis[j]=dis[x]+tu[i].w;
if(inq[j]==0){
q.push((edg){dis[j],j});
}
}
}
}
}
int s,t;
int main(){
cin>>n>>m>>k>>s>>t;
s++;t++;
for(int i=0;i<m;i++){
int u,v,w;
cin>>u>>v>>w;u++;v++;
edge(u,v,w);edge(v,u,w);
for(int j=1;j<=k;j++){
edge(u+j*n,v+j*n,w);
edge(v+j*n,u+j*n,w);
edge(u+(j-1)*n,v+j*n,0);
edge(v+(j-1)*n,u+j*n,0);
}
}
dij(s);
int ans=2147483647;
for(int i=0;i<=k;i++){
// cout<<dis[t+(i+1)*n]<<" ";
ans=min(ans,dis[t+(i+1)*n]);
}
cout<<ans<<endl;
return 0;
}