#include<bits/stdc++.h>
using namespace std;
constexpr int N = 500005;
int deg[N][20],n,m,k,s,t;
struct Node {
int v , w , deg;
friend bool operator < (Node a,Node b){
return a.w > b.w;
}
};
vector<Node> G[N];
void bfs(int cur) {
priority_queue<Node> q;
q.push({cur,0,0});
deg[cur][0] = 0;
while(!q.empty()) {
int u = q.top().v;
int w = q.top().w;
int deg1 = q.top().deg;
q.pop();
for(auto v : G[u]) {
if(deg[v.v][deg1] > w + v.w) {
deg[v.v][deg1] = w + v.w;
q.push({v.v,w+v.w,deg1} );
}
if(deg1 < k && deg[v.v][deg1 + 1] > w) {
deg[v.v][deg1 + 1] = w;
q.push({v.v,w,deg1 + 1});
}
}
}
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
cin >> n >> m >> k;
cin >> s >> t;
for(int i = 1 ; i <= m ; i++) {
int u , v , w;
cin >> u >> v >> w;
G[u].push_back({v,w,0});
G[v].push_back({u,w,0});
}
memset(deg,0x3f,sizeof(deg));
bfs(s);
int minn = 1000000;
for(int i = 0 ; i <= k ; i++) {
minn = min(minn , deg[t][i]);
}
cout << minn;
}