#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e15;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> G(N, vector<long long>(N, INF));
  vector<pair<long long, long long>> E(M);
  vector<long long> cost(M);
  for (long long i = 0; i < N; i++) G.at(i).at(i) = 0;
  for (long long i = 0; i < M; i++) {
    long long A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    G.at(A).at(B) = C;
    G.at(B).at(A) = C;
    E.at(i) = {A, B};
    cost.at(i) = C;
  }
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  vector<bool> fg(M, true);
  for (long long i = 0; i < M; i++) {
    for (long long s = 0; s < M; s++) {
      for (long long t = s + 1; t < M; t++) {
        long long A = G[s][E.at(i).first] + cost.at(i) + G[E.at(i).second][t];
        if (A == G[s][t]) fg.at(i) = false;
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < M; i++) {
    if (fg.at(i)) ans++;
  }
  cout << ans << endl;
}
