#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
bool prime(long long x) {
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
long long kai(long long x) {
  if (x == 1) return 1;
  return kai(x - 1) * x;
}
long long mod_pow(long long x, long long y, long long moder) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % moder;
    x = x * x % moder;
    y >>= 1;
  }
  return res;
}
long long n, m, a[1145], b[1145], c[1145];
long long d[114][114];
bool cnt[1145];
long long ans;
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = 1145141919364364;
    }
  }
  for (long long i = 0; i < m; i++) {
    d[a[i] - 1][b[i] - 1] = c[i];
    d[b[i] - 1][a[i] - 1] = c[i];
  }
  for (long long k = 0; k < n; k++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < n; j++) {
      if (d[j][a[i] - 1] - d[j][b[i] - 1] == c[i]) cnt[i] = true;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (cnt[i]) ans++;
  }
  cout << m - ans << endl;
}
