#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int A[1010] = {}, B[1010] = {}, C[1010] = {};
  int G[110][110] = {};
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i] >> C[i];
    G[A[i]][B[i]] = C[i];
    G[B[i]][A[i]] = C[i];
  }
  int WF[110][110] = {};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (G[i][j] > 0)
        WF[i][j] = G[i][j];
      else if (i != j)
        WF[i][j] = 1e9;
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        WF[i][j] = min(WF[i][j], WF[i][k] + WF[k][j]);
      }
    }
  }
  int ans = 0;
  for (int e = 0; e < M; e++) {
    bool necessary = false;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (WF[i][j] == WF[A[e]][i] + WF[j][B[e]] + C[e]) necessary = true;
      }
    }
    if (necessary) ans++;
  }
  cout << M - ans << endl;
}
