#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(a, b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define DBG printf("this is a input\n")
#define fi first
#define se second
#define mk(a, b) make_pair(a,b)
#define p_queue priority_queue
int n , m , k, s, e;
int head[10005],cnt = 0;
int dis[10005][105];
struct e
{
int to , w, next;
}edge[200005];
struct node
{
int v, len , times;
bool operator < (const node& no)const{
return no.len < len;
}
node(int a, int b ,int c):v(a),len(b),times(c){};
};
void add(int f, int t , int c)
{
edge[cnt].to = t;
edge[cnt].w = c;
edge[cnt].next = head[f];
head[f] = cnt ++;
}
void dijkstra()
{
p_queue <node> q;
node noe(s,0,0);
dis[s][0] = 0;
q.push(noe);
while(!q.empty())
{
node no = q.top();
q.pop();
for(int i = head[no.v] ; i != -1 ; i = edge[i].next)
{
int v = edge[i].to , w = edge[i].w;
if(no.times < k && dis[v][no.times+1] > dis[no.v][no.times])
{
dis[v][no.times+1] = dis[no.v][no.times];
q.push(node(v, dis[v][no.times+1], no.times + 1));
}
if(dis[v][no.times] > dis[no.v][no.times] + w)
{
dis[v][no.times] = dis[no.v][no.times] + w;
q.push(node(v,dis[v][no.times],no.times));
}
}
}
}
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
mem(head,-1);
mem(dis,INF);
cin>>n>>m>>k;
cin>>s>>e;
for(int i = 1 ; i <= m ; i ++)
{
int u, v, w;
cin>>u>>v>>w;
add(u,v,w);
add(v,u,w);
}
int ans = INF;
dijkstra();
for(int i = 0 ; i <= k ; i ++)
ans = min(ans,dis[e][i]);
cout<<ans<<endl;
}