#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(m), B(m), C(m);
  for (int i = 0; i < m; i++) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
  }
  vector<vector<int> > X(n, vector<int>(n, 10000000));
  for (int i = 0; i < n; i++) {
    X[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    X[A[i]][B[i]] = C[i];
    X[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++) {
        X[i][j] = min(X[i][j], X[i][k] + X[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    int a = A[i];
    int b = B[i];
    for (int j = 0; j < n; j++) {
      if (llabs(X[j][a] - X[j][b]) == C[i]) {
        ans--;
        goto LAST;
      }
    }
  LAST:;
  }
  cout << ans << endl;
  return 0;
}
