#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  const int INF = 1000000007;
  vector<vector<int>> G(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++) G.at(i).at(i) = 0;
  vector<pair<int, int>> E(M);
  vector<int> C(M);
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G.at(a).at(b) = c;
    G.at(b).at(a) = c;
    E.at(i) = make_pair(a, b);
    C.at(i) = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        G.at(i).at(j) = min(G.at(i).at(j), G.at(i).at(k) + G.at(k).at(j));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    bool ok = true;
    int a = E.at(i).first;
    int b = E.at(i).second;
    for (int s = 0; s < N; s++) {
      for (int t = s + 1; t < N; t++) {
        if (G.at(s).at(t) == G.at(s).at(a) + C.at(i) + G.at(b).at(t)) {
          ok = false;
        }
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
