#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <sstream>
//#include <fstream>

using namespace std;

#define M 100000000

int t[100][100];

void mst (vector <int>& pi, vector <int>& cost )
{
	int n = pi.size();
	int i;

	vector <bool> v (n, false );

	do{
		int mincost = M;
		int u;

		// costªÅ¬ÆÈém[huðIð·é
		for (i = 0; i < n; ++i ){
			if (!v[i] && cost[i] < mincost ){
				mincost = cost[i];
				u = i;
			} // end if
		} // end for

		v[u] = true;
	
		for (i = 0; i < n; ++i ){
			// Ü¾ÜÜêÄ¢È¢m[hÌRXgÌXV
			if (!v[i] && t[u][i] < cost[i] ){
				cost[i] = t[u][i];
				pi[i] = u;
			} // end if
		} // end for		 
		
	} while ((int)count (v.begin(), v.end(), true ) != n );// end while
}

int main()
{

//	cut here before submit 
//	freopen("testcase.cdl", "r", stdin);

	string str = "";
	int n,m;	// n: jÕÌÓ m: jÕðÔ¹Ì

	while (getline (cin, str ) ) {
		stringstream ssn(str);
		ssn >> n;
		if (n == 0){
			break;
		} // end if
		getline (cin, str );
		stringstream ssm (str );
		ssm >> m;

		int i, j;
		for (i = 0; i < 100; ++i ){
			for (j = 0; j < 100; ++j ){
				t[i][j] = M;
			} // end for
		} // end for 

		for (i = 0; i < m; ++i ){
			int from, to, dist;
			getline (cin, str );
				while (str.find(',') != string::npos ){
				str = str.replace (str.find (','), 1, " " );
			} // end while
			stringstream ss (str );
			ss >> from >> to >> dist;
			t[from][to] = dist;
			t[to][from] = dist;
		} // end for

		vector <int> len (n, M );
		vector <int> path (n, -1 );
		len[0] = 0;
		path[0] = -1;

		mst (path, len );

		int res = accumulate (len.begin(), len.end(), 0 );
		
		map <int, int> edge;
		for (i = 0; i < n; ++i ){
			int curr = i;
			while (path[curr] != -1 ){
				edge[curr] = path[curr];
				curr = path[curr];
			} // end while

		} // end for

		cout << (res/100 - edge.size() ) << endl;

	} // end while

	return 0;
}