#include <bits/stdc++.h>

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define Rrep(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int c, n, m, s, d;
int a, b, f;
struct edge {int to, cost;};
vector<edge> G[105];
vector<vector<int> > dp(11, vector<int>(105, 0));

void dijkstra(int s, int a) {
	priority_queue<P, vector<P>, greater<P> > que;
	rep(i, 105) dp[a][i] = INF;
	dp[a][s] = 0;
	que.push(P(0, s));

	while(!que.empty()) {
		P p = que.top(); que.pop();
		int tmp = p.second;
		if(dp[a][tmp] < p.first) continue;
		rep(i, G[tmp].size()) {
			int to = G[tmp][i].to;
			int cost = (a == 0) ? G[tmp][i].cost + dp[a][tmp] : min(G[tmp][i].cost + dp[a][tmp], G[tmp][i].cost / 2 + dp[a - 1][tmp]);
			if(dp[a][to] > cost) {
				dp[a][to] = cost;
				que.push(P(-cost, to));
			}
		}
	}

}

int main() {
	while(scanf("%d %d %d %d %d", &c, &n, &m, &s, &d)) {
		s--; d--;
		if(c == 0) return 0;
		rep(i, m) {
			scanf("%d %d %d", &a, &b, &f); 
			a--; b--;
			G[a].push_back((edge){b, f});
			G[b].push_back((edge){a, f});
		}
		int ans = INF;
		rep(i, c + 1) dijkstra(s, i);
		printf("%d\n", dp[c][d]);

		rep(i, 105){
      		G[i].erase(G[i].begin(), G[i].end());
    	}
    	rep(i, 11){
      		dp[i].erase(dp[i].begin(), dp[i].end());
    	}
	}
	return 0;
}