#include <bits/stdc++.h>
using namespace std;
double pi = 3.141592653589793;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long fld[105][105];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) fld[i][j] = 1000000007;
  long long a[22000], b[22000], c[22000];
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    fld[a[i]][b[i]] = c[i];
    fld[b[i]][a[i]] = c[i];
  }
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    bool c = false;
    for (long long k = 0; k < n; k++) {
      if (fld[a[i]][b[i]] > fld[a[i]][k] + fld[k][b[i]]) c = true;
    }
    if (c) ans++;
  }
  cout << ans << endl;
  return 0;
}
