
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

template <class _T1, class _T2>
class kruskal_branch {
public:
    _T1 node1, node2;
    _T2 weight;
    kruskal_branch(_T1 n1, _T1 n2, _T2 w) : node1(n1), node2(n2), weight(w) {;}
    bool operator> (const kruskal_branch<_T1, _T2> &p) const { return (weight > p.weight); }
};

template <class _T1, class _T2>
class kruskal {
public:
    typedef kruskal_branch<_T1,_T2> kruskal_branch_t;
    typedef priority_queue<kruskal_branch_t, vector<kruskal_branch_t>, greater<kruskal_branch_t> > kruskal_queue_t;

private:
    int node_num;
    kruskal_queue_t queue;
    set<set<_T1> * > tree;
    vector<set<_T1> * > node;
    kruskal_queue_t mintree;

    void free(void){
        queue = kruskal_queue_t();
        FOREACH(it, tree) delete (*it);
        node.resize(0);
    }
    void print(void){
        printf("[tree]\n");
        FOREACH(it, tree){
            printf("  tree[%p]", *it);
            set<_T1> *s = *it;
            FOREACH(it2, *s) printf(", %d", *it2);
            printf("\n");
        }
        printf("[node]\n");
        REP(i, node_num){
            set<_T1> *s = node[i];
            printf("  node[%d] -> tree[%p]", i, s);
            FOREACH(it2, *s) printf(", %d", *it2);
            printf("\n");
        }
        printf("\n");
    }

public:
    kruskal(int n) : node_num(n){ free(); }
    ~kruskal(void){ free(); }
    void branch_add(kruskal_branch_t &b){ queue.push(b); }
    kruskal_queue_t &mintree_get(void){ return mintree; }

    int solve(){
        node.resize(node_num);

        REP(i,node_num){
            set<_T1> *s = new set<_T1>; s->insert(i);
            tree.insert(node[i] = s);
        }

        for(; !queue.empty(); queue.pop()){
            //print();

            const kruskal_branch_t &b = queue.top();
            pf("node1 = %d, node2 = %d, weight = %d\n", b.node1, b.node2, b.weight);
            if(node[b.node1] != node[b.node2]){
                mintree.push(b);
                set<_T1> *newset = node[b.node1];
                newset->insert(ALL(*node[b.node2]));
                ITER(tree) it = tree.find(node[b.node2]);
                if(it != tree.end()) tree.erase(it);

                FOREACH(it, *newset){
                    node[*it] = newset;
                }
            }
        }
        //print();
        return 0;
    }
};

int solve(int n, kruskal<int,int> &k){
    k.solve();
    kruskal<int,int>::kruskal_queue_t &mintree = k.mintree_get();

    int total = 0;
    for(; !mintree.empty(); mintree.pop()){
        const kruskal<int,int>::kruskal_branch_t &b = mintree.top();
        pf("node1 = %d, node2 = %d, weight = %d\n", b.node1, b.node2, b.weight);
        total += b.weight;
    }
    return total;
}

int main(){
    int n, m, a, b, r;
    while(cin >> n, n){
        kruskal<int,int> k(n);
        cin >> m;
        REP(i,m){
            string s;
            cin >> s;
            sscanf(s.c_str(), "%d,%d,%d", &a, &b, &r);
            kruskal<int,int>::kruskal_branch_t branch(a, b, r/100-1);
            k.branch_add(branch);
        }
        cout << solve(n, k) << endl;;
    }
    return 0;
}