#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int INF = 1e9;

int C, N, M, S, T;

class Cl{
  public:
    int n, c, cost;
    Cl(){}
    Cl(int nn, int cc, int co) { n = nn; c = cc; cost = co; }
    bool operator > (const Cl &tmp) const { return cost > tmp.cost; }
    bool operator < (const Cl &tmp) const { return cost < tmp.cost; }
};

int solve(vector< vector<P> > &v){
  priority_queue<Cl> open;
  open.push(Cl(S, C, 0));
  vector< vector<int> > closed(N, vector<int>(C + 1, INF));
  while(!open.empty()){
    Cl cl = open.top(); open.pop();
    if(closed[cl.n][cl.c] <= cl.cost) continue;
    closed[cl.n][cl.c] = cl.cost;
    REP(i, v[cl.n].size()){
      P nx = v[cl.n][i];
      open.push(Cl(nx.first, cl.c, cl.cost + nx.second));
      if(cl.c > 0) open.push(Cl(nx.first, cl.c - 1, cl.cost + nx.second / 2));
    }
  }
  int res = INF;
  REP(i, C) res = min(res, closed[T][i]);
  return res;
}

int main() {
  while(cin >>C >>N >>M >>S >>T && C && N && M && S && T){
    --T; --S;
    vector< vector<P> > v(N);
    REP(i, M){
      int a, b, f; cin >>a >>b >>f;
      --a; --b;
      v[a].push_back(P(b, f));
      v[b].push_back(P(a, f));
    }
    cout <<solve(v) <<endl;
  }
  return 0;
}