#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;
#define pa pair <int,pair<int,int> >
#define N 11000
#define M 55000
inline int read(){
int x=0;char ch=getchar();
while (ch<'0'||ch>'9') ch=getchar();
while (ch<='9'&&ch>='0') {x=x*10+ch-'0';ch=getchar();}
return x;
}
struct node{
int y,z,next;
}data[M<<1];
bool flag[N][15];
int f[N][15],h[N],n,m,k,S,T,num;
inline int min(int x,int y){
return x<y?x:y;
}
void dijkstra(){
std::priority_queue<pa,vector<pa>,greater<pa> >q;
q.push(make_pair(0,make_pair(S,0)));
memset(f,0x7f,sizeof(f));f[S][0]=0;
while (!q.empty()){
int x=q.top().second.first,level=q.top().second.second;q.pop();
if (flag[x][level]) continue;else flag[x][level]=true;
for (int i=h[x];i;i=data[i].next){
int y=data[i].y,z=data[i].z;
if (f[x][level]+z<f[y][level]){
f[y][level]=f[x][level]+z;
q.push(make_pair(f[y][level],make_pair(y,level)));
}
if (level+1<=k&&f[x][level]<f[y][level+1]){
f[y][level+1]=f[x][level];
q.push(make_pair(f[y][level+1],make_pair(y,level+1)));
}
}
}
}
int main(){
freopen("bzoj2763.in","r",stdin);
n=read();m=read();k=read();
S=read();T=read();
for (int i=1;i<=m;++i){
int x=read(),y=read(),z=read();
data[++num].y=y;data[num].next=h[x];h[x]=num;data[num].z=z;
data[++num].y=x;data[num].next=h[y];h[y]=num;data[num].z=z;
}
dijkstra();
int ans=0x7fffffff;
for (int i=0;i<=k;++i) ans=min(ans,f[T][i]);
printf("%d\n",ans);
return 0;
}