#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  long long d[100][100];
  for (long long i = 0; i < 100; i++)
    for (long long j = 0; j < 100; j++) {
      d[i][j] = (1LL << 60);
    }
  long long a[1000], b[1000], c[1000];
  for (long long i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < M; i++) {
    for (long long k = 0; k < N; k++) {
      if (d[a[i]][b[i]] + d[b[i]][k] == d[a[i]][k] ||
          d[k][a[i]] + d[a[i]][b[i]] == d[k][b[i]]) {
        ans++;
        break;
      }
    }
  }
  cout << M - ans << endl;
  return 0;
}
