#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
long long V, E;
long long dist2[110][110];
void warshall_floyd() {
  for (long long k = 0; k < (V); k++) {
    for (long long i = 0; i < (V); i++) {
      for (long long j = 0; j < (V); j++) {
        dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
      }
    }
  }
}
signed main() {
  cin >> V >> E;
  map<pair<long long, long long>, long long> edge;
  for (long long i = 0; i < (V); i++) {
    for (long long j = 0; j < (V); j++) {
      if (i == j)
        dist2[i][j] = 0;
      else
        dist2[i][j] = 1000000000000000000;
    }
  }
  for (long long i = 0; i < (V); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[pair<long long, long long>(a, b)] = c;
    dist2[a][b] = c;
    dist2[b][a] = c;
  }
  warshall_floyd();
  long long ans = 0;
  for (auto x : edge) {
    long long s = x.first.first, t = x.first.second, u = x.second;
    bool b = false;
    for (long long i = 0; i < (V); i++) {
      if (dist2[i][s] + u == dist2[i][t]) {
        b = true;
        break;
      }
    }
    if (!b) ans++;
  }
  cout << ans << '\n';
}
