#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INF = 1001001001;
int main(void) {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> dist(n, vector<ll>(n, INF));
  vector<tuple<ll, ll, ll>> edge;
  for (ll i = (0); i < (m); i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    edge.emplace_back(a, b, c);
  }
  for (ll k = (0); k < (n); k++)
    for (ll i = (0); i < (n); i++)
      for (ll j = (0); j < (n); j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  ll ans = 0;
  for (ll i = (0); i < (m); i++) {
    ll a, b, c;
    tie(a, b, c) = edge[i];
    bool ok = false;
    for (ll j = (0); j < (n); j++) {
      if (dist[j][a] + c == dist[j][b]) ok = true;
    }
    if (!ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
