#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPL(t, x) bool operator<(CRP(t, x)) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define INF(x) FIL(x, 0x3f)
#define CLR0(x) FIL(x, 0)
#define CLR1(x) FIL(x, -1)
typedef long long ll, i64;
const int N = 3e6 + 60, M = N << 1;
int adj[N], dis[N], ecnt;
struct Edge
{
    int nxt, to, len;
} E[M];
inline void _int_addEdge(int f, int t, int l)
{
    ecnt++;
    E[ecnt] = {adj[f], t, l};
    adj[f] = ecnt;
}
inline void addEdge(int f, int t, int l)
{
    _int_addEdge(f, t, l);
    _int_addEdge(t, f, l);
}
void dijkstra(int S)
{
    struct heap_node
    {
        int u, d;
        OPL(heap_node, rhs) { return d > rhs.d; }
    };
    priority_queue<heap_node> H;
    for (INF(dis), H.push({S, dis[S] = 0}); !H.empty(); H.pop())
    {
        int u = H.top().u, d = H.top().d;
        if (dis[u] == d)
            for (int e = adj[u]; e; e = E[e].nxt)
                if (dis[E[e].to] > d + E[e].len)
                    H.push({E[e].to, dis[E[e].to] = d + E[e].len});
    }
}
int main()
{
    int n, m, S, T, K;
    scanf("%d%d%d%d%d", &n, &m, &S, &T, &K);
    for (int i = 0, a, b, r; i < m; i++)
    {
        scanf("%d%d%d", &a, &b, &r);
        for (int k = 0; k <= K; k++)
        {
            addEdge(a + k * n, b + k * n, r);
            if (k) addEdge(a + (k - 1) * n, b + k * n, 0);
        }
    }
    for (int k = 1; k <= K; k++)
        addEdge(S + (k - 1) * n, S + k * n, 0), addEdge(T + (k - 1) * n, T + k * n, 0);
    dijkstra(S);
    printf("%d", dis[T + K * n]);
    return 0;
}