#include<bits/stdc++.h>
using namespace std;
struct Node{
int to,w;
};
struct ycy{
int p;
long long w;
}nod[1000001];
int tot=0;
long long bj[1000001];
void push_up(int x){
if(nod[x].w>nod[x/2].w&&x!=1){
swap(nod[x],nod[x/2]);
push_up(x/2);
}
}
void push_down(int x){
if(x*2+1<=tot&&nod[x*2].w<nod[x*2+1].w&&nod[x*2].w<nod[x].w){
swap(nod[x*2],nod[x]);
push_down(x*2);
}
else if(x*2+1<=tot&&nod[x*2+1].w<nod[x].w){
swap(nod[x*2+1],nod[x]);
push_down(x*2+1);
}
else if(x*2==tot&&nod[x*2].w<nod[x].w){
swap(nod[x*2],nod[x]);
push_down(x*2);
}
}
vector<Node>a[1000001];
void bfs(int p,long long w){
if(w>bj[p]){
return;
}
bj[p]=w;
for(auto it:a[p]){
if(bj[it.to]>w+it.w){
nod[++tot]={it.to,w+it.w};
push_up(tot);
bj[it.to]=w+it.w;
}
}
}
int main(){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
int s,t;
scanf("%d%d",&s,&t);
for(int i=1;i<=m;i++){
int u,v;
long long w;
scanf("%d%d%lld",&u,&v,&w);
for(int j=0;j<=k;j++){
a[u+j*n].push_back({v+j*n,w});
a[v+j*n].push_back({u+j*n,w});
if(j<k){
a[u+j*n].push_back({v+(j+1)*n,0});
a[v+j*n].push_back({u+(j+1)*n,0});
a[v+j*n].push_back({u+j*n,w});
a[u+j*n].push_back({v+j*n,w});
}
}
}
for(int i=0;i<=(k+1)*n;i++){
bj[i]=1e17;
}
nod[++tot]={s,0};
while(tot){
bfs(nod[1].p,nod[1].w);
swap(nod[1],nod[tot]);
tot--;
push_down(1);
}
printf("%lld",bj[t+k*n]);
return 0;
}