#include <bits/stdc++.h>

using namespace std;

class Segment { 
public:
	int u, v, distance; 
};


int point[101];
int height[101];
Segment arr[10001];

int find(int root) {
	while (root != point[root]) {
		root = point[root];
	}
	return root;
}

bool unit(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) {
		return false;
	}

	if (height[x]<height[y]) {
		point[x] = y;
	}
	else {
		point[y] = x;
		if (height[x] == height[y]) {
			height[x]++;
		}
	}
	return true;
}


bool comp(const Segment& e1, const Segment& e2) {
	return e1.distance < e2.distance;
}

int kruskal(int n, int m) {
	sort(arr, arr + m, comp);
	for (int i = 0; i < n; i++) {
		point[i] = i;
		height[i] = 1;
	}

	int sum = 0, cnt = 0;
	for (int i = 0; i < m; i++) {
		if (cnt == n - 1) {
			break;
		}
		if (unit(arr[i].u, arr[i].v)) {
			sum += arr[i].distance;
			cnt++;
		}
	}
	return sum / 100 - cnt;
}

int main(void) {
	int n, m;
	while (cin >> n, n) {
		cin >> m;
		for (int i = 0; i < m; i++)
			scanf("%d,%d,%d", &arr[i].u, &arr[i].v, &arr[i].distance);
		cout << kruskal(n,m) << endl;
	}
	return 0;
}
