#include<iostream>
#include<cstdio>
#include<algorithm>
const int N = 100000;
int par[N];
int rank[N];
 
void init(int n){
    for (int i = 0; i < n; ++i){
        par[i] = i;
        rank[i] = 0;
    }
}
 
int find(int x){
    if (par[x] == x)return x;
    return par[x] = find(par[x]);
}
 
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y)return;
    if (rank[x] < rank[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if (rank[x] == rank[y])rank[x]++;
    }
}
 
bool same(int x, int y){
    return find(x) == find(y);
}
 
struct edge {
    int u, v, cost;
};
 
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}
 
edge es[1000000];
int V, E;
 
int kruskal(){
    std::sort(es, es + E, comp);
    init(V);
    int res = 0;
    for (int i = 0; i < E; ++i){
        edge e = es[i];
        if (!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}
 
int main(){
    while (1){
        scanf("%d", &V);
        if (V == 0)break;
        scanf("%d", &E);
        for (int i = 0; i < E; ++i){
            int a, b, c;
            scanf("%d,%d,%d", &a, &b, &c);
            es[i].u = a, es[i].v = b, es[i].cost = c;
        }
        int ans = kruskal();
        printf("%d\n", ans / 100 - V + 1);
    }
    return 0;
}