#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>


using namespace std;

const int INF = 1e9 + 10;

class Dijkstra {
#define MAX_V 101
  typedef pair<int, int> P;

private:
  struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) { }
  };

  int V;
  vector<Edge> G[MAX_V];

public:

  Dijkstra(int V): V(V) { 
    if (V >= MAX_V) {
      assert(false);
    }
  }

  void AddEdge(int from, int to, int cost) {
    G[from].push_back(Edge(to, cost));
  }

  vector<int> Solve(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> d(V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
      P p = que.top(); que.pop();
      int v = p.second;
      if (d[v] < p.first) {
        continue;
      }
      for (int i = 0; i < G[v].size(); i++) {
        Edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }

    return d;
  }
};



int main() {
  while (true) {
    int n, m;
    cin >> n;
    if (n == 0) {
      break;
    }
    Dijkstra dijkstra(n);
    cin >> m;
    for (int i = 0; i < m; i++) {
      int a, b, d;
      char split;
      cin >> a >> split >> b >> split >> d;
      dijkstra.AddEdge(a, b, d);
      dijkstra.AddEdge(b, a, d);
    }

    int ans = INF;
    for (int i = 0; i < n; i++) {
      vector<int> d = dijkstra.Solve(i);
      int tmp = accumulate(d.begin(), d.end(), 0);
      ans = min(ans, tmp);
    }

    cout << ans / 100 - (n - 1) << endl;
  }
  return 0;
}