#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef pair<int, int> pii;
const int N = 4e6 + 10, M = 2e5 + 10, inf = 0x3f3f3f3f;
int e[N], ne[N], h[M], w[N], idx;
priority_queue<pii, vector<pii>, greater<pii>> hp;
int d[M];
bool vis[M];
void add(int a, int b, int c)
{
e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++;
}
void dijk(int x)
{
memset(d, 0x3f, sizeof d);
d[x] = 0;
hp.push({0, x});
while (!hp.empty())
{
auto t = hp.top();
hp.pop();
if (vis[t.second])
continue;
vis[t.second] = true;
for (int i = h[t.second]; i != -1; i = ne[i])
{
int j = e[i];
if (d[j] > d[t.second] + w[i])
{
d[j] = d[t.second] + w[i];
hp.push({d[j], j});
}
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
memset(h, -1, sizeof h);
int n, m, k;
cin >> n >> m >> k;
int s, t;
cin >> s >> t;
for (int i = 0; i < m; i++)
{
int a, b, c;
cin >> a >> b >> c;
add(a, b, c), add(b, a, c);
for (int j = 1; j <= k; j++)
{
add(a + j * n, b + j * n, c), add(b + j * n, a + j * n, c);
add(a + (j - 1) * n, b + j * n, 0), (b + (j - 1) * n, a + j * n, 0);
}
}
dijk(s);
int ans = d[t];
for (int i = 1; i <= k; i++)
ans = min(ans, d[t + i * n]);
cout << ans << endl;
return 0;
}