#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1ll << 60;
ll N, M;
ll V[110][110];
ll A[1010], B[1010], C[1010];
ll used[110][110];
int main(int argc, char **argv) {
  for (ll i = (0); i < (ll)(110); ++i)
    for (ll j = (0); j < (ll)(110); ++j) V[i][j] = INF;
  cin >> N >> M;
  for (ll i = (0); i < (ll)(M); ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    V[a][b] = V[b][a] = c;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  for (ll v = (0); v < (ll)(N); ++v)
    for (ll s = (0); s < (ll)(N); ++s)
      for (ll t = (0); t < (ll)(N); ++t)
        V[s][t] = min(V[s][t], V[s][v] + V[v][t]);
  ll res{M};
  for (ll i = (0); i < (ll)(M); ++i) {
    ll ok{false};
    for (ll j = (0); j < (ll)(N); ++j) {
      if (V[j][A[i]] == V[j][B[i]] + C[i]) ok = true;
    }
    if (ok) --res;
  }
  std::cout << res << std::endl;
}
