#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

struct edge { int to, cost; };
typedef pair<int, int> P;

const int INF = 1e+9;
const int MAX_V = 100;

int n, m;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

int prim(){
	bool vis[MAX_V];
	V = n;
	int res = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	fill(vis, vis + V, false);
	d[0] = 0;
	que.push(P(0, 0));
	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(vis[v]) continue;
		vis[v] = true;
		res += p.first;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost){
				d[e.to] = e.cost;
				que.push(P(e.cost, e.to));
			}
		}
	}
	return res;
}


/*
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];

int prim(){
	for(int i=0 ; i < n ; i++ ){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	int res = 0;
	
	while( true ){
		int v = -1;
		for(int u=0 ; u < n ; u++ ){
			if( !used[u] && (v == -1 || mincost[u] < mincost[v]) ){
				v = u;
			}
		}
		
		if(v == -1) break;
		used[v] = true;
		res += mincost[v];
		
		for(int u=0 ; u < n ; u++ ){
			mincost[u] = min( mincost[u] , cost[v][u] );
		}
	}
	return res;
}
*/
// 文字列sを文字c区切りで分割して返す
vector<string> split_string(string s, char c){
	string str;
	vector<string> vs;
	s.push_back( c );
	
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == c ){
			if( !str.empty() ){
				vs.push_back( str );
				str.clear();
			}
		}else{
			str.push_back( s[i] );
		}
	}
	return vs;
}

// stringをintに変換
int s_to_i(string s){
	int n=0;
	for(int i=0 ; i < s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}

void add_edge(int u, int v, int c){
	G[u].push_back((edge){v, c});
	G[v].push_back((edge){u, c});
	//cost[u][v] = cost[v][u] = c;
}

void init(){
	for(int i=0;i<MAX_V;i++) G[i].clear();
	//fill(cost[0], cost[MAX_V], INF);
}

int main(){
	while( cin >> n , n ){
		init();
		cin >> m;
		cin.ignore();
		for(int i=0 ; i < m ; i++ ){
			string s;
			getline(cin,s);
			vector<string> vs = split_string( s , ',' );
			int u = s_to_i( vs[0] );
			int v = s_to_i( vs[1] );
			int c = (s_to_i( vs[2] ) - 100) / 100;
			add_edge(u, v, c);
		}
		int ans = prim();
		cout << ans << endl;
	}
}