#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N, vector<int>(N, INT_MAX));
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < (M); i++) {
    int c;
    cin >> A[i] >> B[i] >> c;
    --A[i];
    --B[i];
    G[A[i]][B[i]] = c;
    G[B[i]][A[i]] = c;
  }
  for (int k = 0; k < (N); k++) {
    for (int i = 0; i < (N); i++) {
      for (int j = 0; j < (N); j++) {
        if (G[i][k] == INT_MAX || G[k][j] == INT_MAX) continue;
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  int answer = M;
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      if (G[j][A[i]] + G[A[i]][B[i]] == G[j][B[i]]) {
        --answer;
        break;
      }
    }
  }
  cout << answer << endl;
  return 0;
}
