#include <iostream>
#include <algorithm>
#define MAX 100
#define INF 999999

using namespace std;

bool visit[MAX + 1][MAX + 1];
int v[MAX + 1][MAX + 1];
int rote[MAX + 1][MAX + 1];
int c,n,m,s,d,a,b,f,x,y;

int dijkstra(void){

  fill( v[0] , v[MAX + 1] , INF );
  fill( visit[0] , visit[MAX + 1] , false );

  v[c][s - 1] = 0;

  while(1){

    int min_i = -1, min_j;

    for( int i = y ; i <= x ; i++ ){
      for( int j = 0 ; j <= c ; j++ ){
	if( (v[j][i] < v[min_i][min_j] || min_i == -1) && !visit[j][i] ){
	  min_i = i;
	  min_j = j;
	}
      }
    }

    if( min_i == -1 ) break;
    visit[min_j][min_i] = true;

    for( int i = y ; i <= x ; i++ ){
      v[min_j][i] = min( v[min_j][i] , v[min_j][min_i] + rote[min_i][i] );
      if( min_j > 0 ){
	v[min_j - 1][i] = min( v[min_j - 1][i] , v[min_j][min_i] + rote[min_i][i]/2 );
      } 
    }


  }

  int ans = INF;
  for( int i = 0 ; i <= c ; i++ ){
    ans = min( ans , v[i][d - 1] );
  }
  return ans;
}



int main(void){

  fill( rote[0] , rote[MAX] , INF );
  
  while( cin >> c >> n >> m >> s >> d , c + n + m + s + d ){
    
    x = 0;
    y = INF;
    
    for( int i = 0 ; i < m ; i++ ){
      cin >> a >> b >> f;
      rote[a - 1][b - 1] = rote[b - 1][a - 1] = f;
      x = max( x , max(a - 1 , b - 1) );
      y = min( y , min(a - 1 , b - 1) );
    }

    cout << dijkstra() << endl;

  }
  return 0;
}