#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
struct Edge{ int from, to, cost; };

bool comp(const Edge& e1, const Edge& e2){
	return e1.cost < e2.cost;
}

const int N = 100;
vector<Edge> e;

int par[N];
int rank_[N];

int find(int x)
{
	if(x == par[x])
		return x;
	else
		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);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(1){
		int n, m;
		cin >> n;
		if(n == 0)
			break;
		cin >> m;
		
		string str;
		for(int i = 0; i != m; ++i){
			int abc[3] = {};
			cin >> str;
			int count = 0;
			for(size_t i = 0; i != str.size(); ++i){
				if(str[i] == ',')
					count++;
				else {
					abc[count] *= 10;
					abc[count] += str[i] - '0';
				}
			}
			/*cout << abc[0] << endl;
			cout << abc[1] << endl;
			cout << abc[2] << endl;*/
			e.push_back(Edge{abc[0], abc[1], abc[2] / 100 - 1});
		}
		
		for(int i = 0; i != n; ++i){
			par[i] = i;
			rank_[i] = 0;
		}
		
		sort(e.begin(), e.end(), comp);
		
		int ans = 0;
		for(int i = 0; i != n; ++i){
			if(!same(e[i].from, e[i].to)){
				unite(e[i].from, e[i].to);
				ans += e[i].cost;
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}