#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;
const int MAX = 101;
const int INF = (1<<25);
int data[MAX][MAX],n;

void solve(){
  for(int i = 0; i < MAX; i++)
    data[i][i] = 0;

  for(int k = 0; k < MAX; k++)
    for(int i = 0; i < MAX; i++)
      for(int j = 0; j < MAX; j++)
	data[i][j] = min(data[i][j],data[i][k]+data[k][j]);
  

  ll ans = INF;
  for(int i = 0; i < n; i++){
    ll sum = 0;
    bool able = true;
    for(int j = 0; j < n; j++){
      if(data[i][j] == INF){
	able = false;
	break;
      }
      sum += data[i][j];
    }
    ans = min(ans,sum);
  }

  cout << ans/100 - n +1<< endl;
}


void init(){
  for(int i = 0; i < MAX; i++)
    fill(data[i],data[i]+MAX,INF);
}
int main(){
  while(cin >> n && n){
    init();
    int m;
    cin >> m;
    while(m--){
      int from,to,d;
      char c;
      cin >> from >> c >> to >> c >> d;
      data[from][to] = d;
      data[to][from] = d;
    }
    solve();
  }
}