#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
typedef vector<int> Vi;
const int INF = (1<<25);
const int MAX_V = 101;
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

struct edge {
  int to, cost;
  edge(int _to, int _cost) {
    to = _to; cost = _cost;
  }
};

int V;
vector<edge> G[MAX_V];

int dij(int s, int c, int g) {
  priority_queue<Pip, vector<Pip>, greater<Pip> > q;

  int d[11][101];
  for(int i=0; i<11; i++) {
    for(int j=0; j<101; j++) {
      d[i][j] = INF;
    }
  }

  d[c][s] = 0;
  q.push(Pip(0, Pii(s, c)));

  int result = INF;
  while( !q.empty() ) {
    Pip p = q.top(); q.pop();
    int now_cost = p.fr;
    int v = p.sc.fr;
    int c = p.sc.sc;

    if( v == g ) {
      result = now_cost;
      break;
    }

    for(int i=0; i<G[v].size(); i++) {
      edge e = G[v][i];

      int next_cost = d[c][v] + e.cost;
      if( next_cost < d[c][e.to] ) {
	d[c][e.to] = next_cost;
	q.push(Pip(next_cost, Pii(e.to, c)));
      }
      if( c ) {
	next_cost = d[c][v] + e.cost/2;
	if( next_cost < d[c-1][e.to] ) {
	  d[c-1][e.to] = next_cost;
	  q.push(Pip(next_cost, Pii(e.to, c-1)));
	}
      }
    }
  }
  return result;
}

int main() {
  int c, n, m, s, g;
  while( cin >> c >> n >> m >> s >> g, c || n || m || s || g ) {
    for(int i=0; i<n+1; i++) {
      G[i].clear();
    }
      
    s--; g--;
    for(int i=0; i<m; i++) {
      int u, v, cost;
      cin >> u >> v >> cost;
      u--; v--;
      G[u].pb(edge(v, cost));
      G[v].pb(edge(u, cost));
    }
    int ans = dij(s, c, g);
    cout << ans << endl;
  }
}