#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void chmin(T &t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
inline void chmax(T &t, U f) {
  if (t < f) t = f;
}
int dp[1000 + 1][1000 + 1];
int a[1000 + 1], b[1000 + 1], c[1000 + 1];
int n, m;
int i, j, k;
void solve() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = (int)(0); i < (int)(m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dp[a[i]][b[i]] = dp[b[i]][a[i]] = c[i];
  }
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(n); j++) {
      if (i == j)
        dp[i][j] = 0;
      else
        dp[i][j] = INT_MAX / 3;
    }
  }
  for (int i = (int)(0); i < (int)(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 = (int)(0); k < (int)(n); k++) {
    for (int i = (int)(0); i < (int)(n); i++) {
      for (int j = (int)(0); j < (int)(n); j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = (int)(0); i < (int)(m); i++) {
    bool shortest = false;
    for (int j = (int)(0); j < (int)(n); j++)
      if (dp[i][a[j]] + c[i] == dp[i][b[j]]) shortest = true;
    if (shortest) ans--;
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
