#include <bits/stdc++.h>
using namespace std;
long long int dp[101][101];
bool used[101][101];
bool edges[101][101];
int main() {
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    long long int from, to, cost;
    cin >> from >> to >> cost;
    dp[from][to] = dp[to][from] = cost;
    edges[from][to] = edges[to][from] = cost;
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      if (dp[i][j]) continue;
      if (i == j) continue;
      dp[i][j] = (LLONG_MAX / 3);
      ;
    }
  }
  for (long long int k = 1; k <= n; k++) {
    for (long long int i = 1; i <= n; i++) {
      for (long long int j = 1; j <= n; j++) {
        if (dp[i][j] > dp[i][k] + dp[k][j]) {
          dp[j][i] = dp[i][j] = dp[i][k] + dp[k][j];
        } else {
          dp[j][i] = dp[i][j] = dp[i][j];
        }
      }
    }
  }
  for (long long int k = 1; k <= n; k++) {
    for (long long int i = 1; i <= n; i++) {
      for (long long int j = 1; j <= n; j++) {
        if (edges[i][j]) {
          if (dp[i][j] == edges[i][j]) used[i][j] = used[j][i] = true;
        }
        if (edges[i][k]) {
          if (dp[i][j] == edges[i][k] + dp[k][j])
            used[i][k] = used[k][i] = true;
        }
        if (edges[k][j]) {
          if (dp[i][j] == dp[i][k] + edges[k][j])
            used[k][j] = used[j][k] = true;
        }
      }
    }
  }
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = i + 1; j <= n; j++) {
      if (!edges[i][j]) continue;
      cout << i << "-" << j << ": " << used[i][j] << endl;
      if (!used[i][j]) ans++;
    }
  }
  cout << ans << endl;
}
