#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

class UF{
  vi p,r;

public:
  UF(int n):p(n,-1),r(n,0){ }

  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }

  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }

  bool same(int x,int y){return find(x)==find(y);}
};

const int INF= 1e9;

struct edge{
  int from, to, cost;
  edge(int x,int y, int z):from(x),to(y),cost(z){}
  bool operator<(const edge &x)const{ return cost<x.cost; }
};

class Kruskal{
  int n;
  vector< vector<edge> > g;
public:
  Kruskal(int a=0):n(a){ g.resize(n); }

  void AddEdge(int a, int b, int cost){
    g[a].push_back(edge(a,b,cost));
    g[b].push_back(edge(b,a,cost));
  }

  int MinSpanningTree(){
    UF connect(n);
    vector<edge> edges;
    for(int v=0;v<n;v++){
      for(edge e.: g[v])edges.push_back(e);
    }
    sort(edges.begin(), edges.end());
    
    int res = 0;
    for(edge e : edges){
      if(!connect.same(e.from,e.to)){
	res += e.cost;
	connect.unite(e.from,e.to);
      }
    }
    return res;
  }
};

int main(){
  int n,m;
  while(scanf("%d",&n),n){
    Kruskal p(n);
    cin >> m;
    for(int i=0;i<m;i++){
      int a,b,c;
      scanf("%d,%d,%d",&a,&b,&c);
      p.AddEdge(a,b,c/100-1);
    }
    cout << p.MinSpanningTree() << endl;
  }
}