#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M, D[110][110], a[110], b[110], c[110];
  cin >> N >> M;
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < N; j++) {
      if (i != j) {
        D[i][j] = (1LL << 61) - 1;
      } else {
        D[i][j] = 0;
      }
    }
  for (long long i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    D[a[i]][b[i]] = min(D[a[i]][b[i]], c[i]);
    D[b[i]][a[i]] = min(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 = M;
  for (long long i = 0; i < M; i++) {
    bool can = false;
    for (long long j = 0; j < N; j++) {
      if (D[j][a[i]] + c[i] == D[j][b[i]]) can = true;
    }
    if (can) ans--;
  }
  cout << ans << endl;
  return 0;
}
