#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;

int n,m;

class UnionFind{
	vector<int> par;
	vector<int> rank;
public:
	UnionFind(){ }
	UnionFind(int size){ reset(size); }

	void reset(int size){
		par.resize(size);
		rank.resize(size);
		for(int i = 0; i < size; i++) par[i] = i,rank[i] = 0;
	}

	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x,int y){
		x = find(x),y = find(y);
		if(x == y) return ;
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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


struct P{
	int c,f,t;
	bool operator<(const P& x)const{
		return c < x.c;
	}
};

void solve()
{
	cin>>m;
	vector<P> p(m);
	UnionFind uf(n);
	for (int i = 0; i < m; i++){
		int x,y,z;
		scanf("%d,%d,%d",&x,&y,&z);
		p[i].f = x; p[i].t = y; p[i].c = z;
	}
	sort(p.begin(),p.end());
	int cost = 0;
	for (int i = 0; i < m; i++){
		if(!uf.same(p[i].f,p[i].t)){
			uf.unite(p[i].f,p[i].t);
			cost += p[i].c;
		}
	}

	cout << cost / 100 - (n-1) << endl;
}

int main(){
	while(cin>>n,n){
		solve();
	}
    return 0;
}