#include <bits/stdc++.h>
using namespace std;
void Main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> a(m), b(m), c(m);
  for (long long int i = 0; i < (long long int)(m); i++)
    cin >> a[i] >> b[i] >> c[i];
  long long int INF = 1e18;
  vector<vector<long long int> > d(n, vector<long long int>(n, INF));
  for (long long int i = 0; i < (long long int)(m); i++) {
    d[a[i] - 1][b[i] - 1] = c[i];
    d[b[i] - 1][a[i] - 1] = c[i];
  }
  for (long long int k = 0; k < (long long int)(n); k++) {
    for (long long int i = 0; i < (long long int)(n); i++) {
      for (long long int j = 0; j < (long long int)(n); j++) {
        if (d[i][k] < INF && d[k][j] < INF) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }
  long long int res = 0;
  for (long long int i = 0; i < (long long int)(m); i++) {
    bool ok = false;
    for (long long int s = 0; s < (long long int)(n); s++) {
      if (s == a[i] - 1 || s == b[i] - 1) {
        continue;
      }
      if (d[s][a[i] - 1] + c[i] == d[s][b[i] - 1]) {
        ok = true;
        break;
      }
      if (d[s][b[i] - 1] + c[i] == d[s][a[i] - 1]) {
        ok = true;
        break;
      }
    }
    if (!ok) {
      res++;
    }
  }
  std::cout << res << endl;
  ;
}
signed main() {
  Main();
  return 0;
}
