#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
long long mod = 1e9 + 7;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
long long cnt[105][105];
signed main() {
  for (long long i = 0; i < 105; i++) {
    for (long long j = 0; j < 105; j++) {
      if (i != j) {
        cnt[i][j] = INF;
      }
    }
  }
  long long N, M;
  cin >> N >> M;
  vector<long long> a(M), b(M), c(M);
  for (long long i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    cnt[a[i]][b[i]] = min(cnt[a[i]][b[i]], c[i]);
    cnt[b[i]][a[i]] = min(cnt[b[i]][a[i]], c[i]);
  }
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      for (long long k = 0; k < N; k++) {
        cnt[i][j] = min(cnt[i][j], cnt[i][k] + cnt[k][j]);
        cnt[j][i] = min(cnt[j][i], cnt[i][k] + cnt[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < M; i++) {
    for (long long j = 0; j < N; j++) {
      for (long long k = 0; k < N; k++) {
        if (cnt[j][a[i]] + cnt[b[i]][k] + c[i] == cnt[j][k]) {
          ans++;
          goto END;
        }
      }
    }
  END:;
  }
  cout << M - ans << endl;
}
