#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int dp[n][n];
  int s[m], t[m], u[m];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> t[i] >> u[i];
    s[i]--, t[i]--;
    dp[s[i]][t[i]] = u[i];
    dp[t[i]][s[i]] = u[i];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (dp[s[i]][t[i]] < u[i]) ans++;
  }
  cout << ans << endl;
}
