#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int pt[1234], n, m, a, b, d;
vector<pair<int, pair<int, int>>>v;
void f() {
	for0(i, n)pt[i] = i;
	return;
}
int root(int i) {
	if (pt[i] == i)return i;
	else return pt[i] = root(pt[i]);
}
void unite(int a, int b) {
	pt[root(b)] = root(a);
	root(b);
	return;
}
void input() {
	string s; cin >> s;
	int p = 0; bool b00l = 0;
	for (char ch : s) {
		if (ch == ',') {
			if (b00l)b = p; else a = p;
			p = 0; b00l = 1;
		}
		else { p *= 10; p += ch - '0'; }
	}
	d = p;
	v.push_back(mp(d / 100 - 1, mp(a, b)));
}
signed main() {
	while (cin >> n, n) {
		int ans = 0;
		cin >> m;
		v.clear(); f();
		for0(i, m)input(); sort(all(v));
		for (pair<int, pair<int, int>>p : v) {
			a = p.second.first;
			b = p.second.second;
			if (root(a) != root(b)) {
				unite(a, b);
				ans += p.first;
			}
		}
		cout << ans << endl;
	}
}
