#include<iostream>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 100000LL
using namespace std;

int main(){
	int n,m,a,b,d;
	while(1){
		cin>>n;
		if(n==0)break;
		cin>>m;
		long long dist[n][n],dp[n][n];
		rep(i,n)rep(j,n)dist[i][j]=dp[i][j]=(i==j?0:INF);
		rep(i,m){
			scanf("%d,%d,%d",&a,&b,&d);
			dist[a][b]=dist[b][a]=d/100-1;
		}
		rep(k,n){
			rep(i,n){
				rep(j,n){
					dp[i][j]=min(dp[i][j],dp[i][k]+dist[k][j]);
				}
			}
		}
		long long num=INF;
		rep(i,n){
			long long sum=0;
			rep(j,n)sum+=dp[i][j];
			if(sum<num)num=sum;
		}
		cout<<num<<endl;
	}
	return 0;
}