#include<iostream>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
int Read(){
int x = 0; char c = getchar();
while(c<'0'||c>'9') {
c = getchar();
}
while(c>='0'&&c<='9'){
x = x*10 + c -'0';
c = getchar();
}
return x;
}
int ans[2000005];
int head[2000005];
int cnt = 0;
struct EDGE{
int Next;
int To;
int Weight;
}edge[2000005];
void addedge(int x, int v, int w){
cnt++;
edge[cnt].Next = head[x];
edge[cnt].To = v;
edge[cnt].Weight = w;
head[x] = cnt;
}
struct Priority{
int ans;
int id;
bool operator<(const Priority&A)const{
return ans > A.ans;
}
};
bool vis[2000005];
void dijkstra(int n, int m, int k, int s, int t){
priority_queue<Priority>q;
q.push({0,s});
while(!q.empty()){
Priority temp = q.top();
q.pop();
if(vis[temp.id]==1) continue;
vis[temp.id] = 1;
for(int i = head[temp.id]; i!=0; i = edge[i].Next){
int v = edge[i].To;
if(ans[v] > ans[temp.id] + edge[i].Weight){
ans[v] = ans[temp.id] + edge[i].Weight;
q.push({ans[v],v});
}
}
}
return ;
}
int main(){
int n, m, k;
n =Read();m = Read(); k = Read();
int s, t;
s =Read(); t = Read();
for(int i = 1; i<=m; i++){
int a, b, c;
a = Read(); b = Read(); c = Read();
addedge(a,b,c);
addedge(b,a,c);
for(int j = 1; j<=k; j++){
addedge(a + (j-1)*n, b + j*n, 0);
addedge(b + (j-1)*n, a + j*n, 0);
addedge(a + j*n, b + j*n, c);
addedge(b + j*n, a + j*n, c);
}
}
memset(ans,0x3f,sizeof(ans));
ans[s] = 0;
for(int i = 1; i<=k; i++){
addedge(t+(i-1)*n, t+i*n, 0);
}
dijkstra(n, m, k, s, t);
int minn = 0x3f3f3f3f;
for(int i = 0; i<=k; i++){
minn = min(minn, ans[t+i*n]);
}
cout<<minn;
return 0;
}