#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <vector>

#define MAX_N 256

using namespace std;
typedef pair<int, pair<int, int> > edge;//cost, node, node

int n, m;
int parent[MAX_N];
int rank[MAX_N];

void uf_init(int n){
	
	for(int i=0; i<n; ++i){
		parent[i]=i;
		rank[i]=0;
	}
}

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

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

	if(x==y)
		return;
	
	if(rank[x] < rank[y]){
		parent[x] = y;
	}
	else{
		parent[y] = x;
		
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

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

int solve_krascal(const vector<edge> als){

	int res = 0;
	int cnt = 0;
	
	uf_init(n);

	for(int i=0; (i<m && cnt<n-1); ++i){
		
		int a = als[i].second.first,
			b = als[i].second.second;
		
		if(!is_same_group(a, b)){
		
			res += als[i].first;
			unite(a, b);
			cnt++;
		}
	}

	return res/100;
}


int main(){

	while(cin >> n, n){

		vector<edge> als;
		cin >> m;
		
		int a, b, c;
		char cm;
		
		for(int i=0; i<m; ++i){
			
			scanf("%d,%d,%d", &a, &b, &c);
			als.push_back(make_pair(c-100, make_pair(a, b)));
		}

		sort(als.begin(), als.end());

		cout << solve_krascal(als) << endl;

	}

	return 0;
}