#include<iostream>
#include<vector>
#include<cstdio>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    int m,ans = 0;
    vector<pair<int,pair<int,int> > > P;
    bool done[100]={false};
    cin >>m;
    for(int i=0,a,b,c; i<m; i++){
      scanf("%d,%d,%d",&a,&b,&c);
      P.push_back(make_pair(c,make_pair(a,b)));
    }
    sort(P.begin(),P.end());
    ans+=(P[0].first/100)-1;
    done[P[0].second.first] = done[P[0].second.second] = true;
    for(int i=0; i<n-1; i++){
      for(int j=0; j<m; j++){
	if(done[P[j].second.first]^done[P[j].second.second]){
	  ans+=(P[j].first/100)-1;
	  done[P[j].second.first] = done[P[j].second.second] = true;
	  break;
	}
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}