#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, M;
  cin >> N >> M;
  vector<long long int> A(M);
  vector<long long int> B(M);
  vector<long long int> C(M);
  for (long long 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));
  for (long long 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 k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  long long int cnt = 0;
  for (long long int i = 0; i < M; i++) {
    if (G[A[i] - 1][B[i] - 1] < C[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
