#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
struct E {
  ll to, from, cost;
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M;
  cin >> N >> M;
  vector<vector<ll>> v(N, vector<ll>(N, LONG_MAX));
  for (ll i = 0; i < N; i++) v[i][i] = 0;
  vector<E> e(M);
  for (ll i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    e[i].from = a;
    e[i].to = b;
    e[i].cost = c;
    v[a][b] = c;
    v[b][a] = c;
  }
  for (ll k = 0; k < N; k++) {
    for (ll i = 0; i < N; i++) {
      for (ll j = 0; j < N; j++) {
        v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < M; i++) {
    bool ok = false;
    for (ll j = 0; j < N; j++) {
      if (v[e[i].from][i] + e[i].cost == v[e[i].to][i]) ok = true;
    }
    if (ok) ans++;
  }
  cout << M - ans << endl;
  return 0;
}
