#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e15;
using Graph = vector<vector<long long>>;
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);
  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};
  }
  vector<bool> fg(M, true);
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        if (G[i][j] > G[i][k] + G[k][j]) {
          for (long long p = 0; p < M; p++) {
            pair<long long, long long> p1 = {k, j};
            pair<long long, long long> p2 = {j, k};
            if (E.at(p) == p1 || E.at(p) == p2) fg.at(p) = false;
          }
        }
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < M; i++) {
    if (fg.at(i)) ans++;
  }
  cout << ans << endl;
}
