#include <iostream>

using namespace std;
static const int INF = 99999999;
int d[101][101];

void solve()
{
	int n;
	while(cin >> n, n)
	{
		for(int i = 0; i < 101; ++i)
		{
			for(int j = 0; j < 101; ++j)
			{
				d[i][j] = INF;
			}
			d[i][i] = 0;
		}
		int m;
		cin >> m;
		for(int i = 0; i < m; ++i)
		{
			int a, b, dist;
			char c;
			cin >> a >> c >> b >> c >> dist;
			d[a][b] = dist;
			d[b][a] = dist;
		}
		for(int k = 0; k < n; ++k)
		{
			for(int i = 0; i < n; ++i)
			{
				for(int j = 0; j < n; ++j)
				{
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		int min_sum_dist = INF;
		for(int i = 0; i < n; ++i)
		{
			int sum = 0;
			for(int j = 0; j < n; ++j)
			{
				if(d[i][j] != INF)
				{
					sum += d[i][j];
				}
			}
			if(min_sum_dist > sum)
			{
				min_sum_dist = sum;
			}
		}
		cout << min_sum_dist / 100 - 3 << endl;
	}
}

int main()
{
	solve();
	return(0);
}