#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  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];
  for (int i = 0; i < M; i++) a[i]--, b[i]--;
  vector<vector<ll>> Min(N, vector<ll>(N, 1001));
  for (int i = 0; i < M; i++) {
    Min[a[i]][b[i]] = c[i];
    Min[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (Min[i][k] + Min[k][j] < Min[i][j])
          Min[i][j] = Min[i][k] + Min[k][j];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    bool ok = false;
    for (int k = 0; k < N; k++) {
      if (Min[k][a[i]] + c[i] == Min[k][b[i]]) ok = true;
    }
    if (!ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
