#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 7;
const long long MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m), b(m), c(m);
  for (long long i = (0); i < (m); ++i) cin >> a[i] >> b[i] >> c[i];
  long long d[n][n];
  for (long long i = (0); i < (n); ++i)
    for (long long j = (0); j < (n); ++j) d[i][j] = INF;
  for (long long i = (0); i < (n); ++i) d[i][i] = 0;
  for (long long i = (0); i < (m); ++i) {
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = 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]);
  long long maxe = 0;
  for (long long i = (0); i < (n); ++i) {
    for (long long j = (0); j < (n); ++j) {
      maxe = max(maxe, d[i][j]);
    }
  }
  long long ans = 0;
  for (long long i = (0); i < (m); ++i) {
    if (c[i] > maxe) ans++;
  }
  cout << ans << endl;
}
