#include "bits/stdc++.h"
using namespace std;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T> void dbg(T x) { cout << x << "\n"; }
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }


int n, m;

// O(n^2)
using Dist = int;
const int VMAX = 110;
Dist cost[VMAX][VMAX];
Dist d[12][VMAX];
void dijkstra(int s, int a) {
    d[a][s] = 0;
    vector<int> used(n, 0);
    while (1) {
        int v = -1;
        for (int to = 0; to < n; to++) {
            if (used[to]) continue;
            if (v == -1 || d[a][to] < d[a][v]) v = to;
        }
        if (v == -1) break;
        used[v] = 1;
        for (int to = 0; to < n; to++) {
            Dist nd = d[a][v] + cost[v][to];
            if (a > 0) chmin(nd, d[a - 1][v] + cost[v][to] / 2);
            if (nd < d[a][to]) d[a][to] = nd;
        }
    }
}

void init() {
    fill_n(*d, 12 * VMAX, INF);
    fill_n(*cost, VMAX * VMAX, INF);
}

int main() {
    int c, s, t;
    while (cin >> c >> n >> m >> s >> t, c) {
        init();
        s--; t--;
        rep(i, m) {
            int a, b, f; cin >> a >> b >> f;
            a--; b--;
            cost[a][b] = cost[b][a] = f;
        }
        rep(a, c + 1) dijkstra(s, a);
        cout << d[c][t] << "\n";
    }

    return 0;
}

