#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int N, M, a[21000], b[21000], c[21000];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i] >> c[i];
  vector<vector<long long int> > G(N, vector<long long int>(N, INF));
  for (int i = 0; i < N; i++) {
    G[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    G[a[i] - 1][b[i] - 1] = c[i];
    G[b[i] - 1][a[i] - 1] = c[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  long long int ans = M;
  for (int i = 0; i < M; i++) {
    bool shortest = false;
    for (int j = 0; j < N; j++) {
      if (G[j][a[i] - 1] + c[i] == G[j][b[i] - 1]) {
        shortest = true;
        break;
      }
    }
    if (shortest) ans--;
  }
  cout << ans << endl;
}
