#include <bits/stdc++.h>
using namespace std;
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 ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pint>>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<ll>> dist(N, vector<ll>(N, 1e9 + 7));
  for (ll i = 0; i < (ll)(N); i++) {
    for (ll j = 0; j < (ll)(N); j++) {
      dist[i][j] = 1e9 + 7;
    }
    dist[i][i] = 0;
  }
  vector<ll> a(M), b(M), c(M);
  for (ll i = 0; i < (ll)(M); i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (ll i = 0; i < (ll)(N); i++) {
    for (ll j = 0; j < (ll)(N); j++) {
      for (ll k = 0; k < (ll)(N); k++) {
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
      }
    }
  }
  int res = 0;
  for (ll i = 0; i < (ll)(M); i++) {
    if (c[i] > dist[a[i]][b[i]]) ++res;
  }
  cout << res << endl;
}
