#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define F first
#define S second
using namespace std;
int n,m;
int p[111];
void init(){for(int i=0;i<n;i++)p[i]=i;}
int find(int x){return p[x]=(p[x]==x?x:find(p[x]));}
bool same(int x,int y){return find(x)==find(y);}
void merge(int x,int y){p[find(x)]=find(y);}
int main(void){
  while(true){
    scanf("%d",&n);
    if(!n) break;
    init();
    priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > que;
    scanf("%d",&m);
    for(int i = 0; i < m; i++){
      int a,b,c;
      scanf("%d,%d,%d",&a,&b,&c);
      que.push(make_pair(c/100-1,make_pair(a,b)));
    }
    int res = 0;
    while(--n){
      while(same(que.top().S.F,que.top().S.S)) que.pop();
      res += que.top().F;
      merge(que.top().S.F,que.top().S.S);
      que.pop();
    }
    printf("%d\n",res);
  }
}