#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  vector<vector<int>> d(N, vector<int>(N, 100000000));
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }
  for (int i = 0; i < N; i++) d[i][i] = 0;
  for (int i = 0; i < M; 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 (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = M;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) goto minus;
    }
    continue;
  minus:
    ans--;
  }
  cout << ans << endl;
}
