#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int a[1002], b[1002], c[1002];
  int dp[1002][1002];
  const int inf = 100000000;
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = inf;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    dp[a[i]][b[i]] = min(c[i], dp[a[i]][b[i]]);
    dp[b[i]][a[i]] = min(c[i], dp[b[i]][a[i]]);
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    bool flag = false;
    for (int j = 0; j < n; j++) {
      if (dp[j][a[i]] + c[i] == dp[j][b[j]]) {
        flag = false;
      }
    }
    if (flag) ans--;
  }
  cout << ans << endl;
  ;
  return 0;
}
