#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#define fr first
#define sc second
using namespace std;
#define INF 10000000
typedef pair<int,int> iiP;
typedef pair<int,iiP> P;
struct edge{
  int to,cost;
  edge(){}
  edge(int to,int cost):to(to),cost(cost){};
};
int c,n,m;
int S,G;
int min_cost[101][10];
bool used[101][10];
vector< vector<edge> > info;
int solve();
int main(){
  while(cin >> c >> n >> m >> S >> G && (c||n||m||S||G)){
  for(int i=0;i<=n;i++){
    for(int j=0;j<=c;j++){
      min_cost[i][j] = INF;
      used[i][j] = false;
    }
  }
  info.resize(n + 1);
  for(int i=0,a,b,f;i<m;i++){
    cin >> a >> b >> f;
    info[a].push_back(edge(b,f));
    info[b].push_back(edge(a,f));
  }
  cout << solve() << endl;

  info.clear();
  }
}
int solve(){
  priority_queue< P,vector<P>,greater<P> > que;

  min_cost[S][c] = 0;
  que.push(P(0,iiP(S,c)));

  while(!que.empty()){
    P p = que.top();
    int cost = p.fr,now = p.sc.fr,KEN = p.sc.sc;
    que.pop();

    if( now == G) return cost;

    if( used[now][KEN] ) continue;
    used[now][KEN] = true;

    for(int i = 0,l = info[now].size();i < l;i++){
      edge e = info[now][i];
      if(cost + e.cost < min_cost[e.to][KEN]){
        min_cost[e.to][KEN] = cost + e.cost;
        que.push(P(min_cost[e.to][KEN],iiP(e.to,KEN)));
      }
      if(KEN != 0){
        if( cost + e.cost/2 < min_cost[e.to][KEN-1] ){
          min_cost[e.to][KEN-1] = cost + e.cost/2;
          que.push(P(min_cost[e.to][KEN-1],iiP(e.to,KEN-1)));
        }
      }
    }
  }
}