#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int lim = 101;
int n, m;
int dp[lim][lim];
int main() {
  int n, m;
  cin >> n >> m;
  const int INF = 1e9;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++)
      if (i != j) dp[i][j] = INF;
  }
  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < (int)(n); i++) {
    dp[a[i]][b[i]] = min(dp[a[i]][b[i]], c[i]);
    dp[b[i]][a[i]] = min(dp[b[i]][a[i]], c[i]);
  }
  for (int k = 0; k < (int)(n); k++) {
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(n); j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < (int)(m); i++) {
    bool flag = false;
    for (int j = 0; j < (int)(n); j++) {
      if (dp[j][a[i]] + c[i] == dp[j][b[i]]) flag = true;
    }
    if (flag) ans--;
  }
  cout << ans << endl;
}
