#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<P>> edges(N);
  map<P, int> counts;
  for (int i = 0; i < (M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edges[a].push_back({c, b});
    edges[b].push_back({c, a});
    counts[{min(a, b), max(a, b)}] = 0;
  }
  for (int i = 0; i < (N); ++i) {
    priority_queue<pair<int, P>> q;
    q.push({0, {i, -1}});
    vector<bool> visited(N);
    while (!q.empty()) {
      pair<int, P> p = q.top();
      q.pop();
      int v = p.second.first;
      int pv = p.second.second;
      if (visited[v]) continue;
      visited[v] = true;
      if (pv >= 0) counts[{min(v, pv), max(v, pv)}]++;
      int cost = p.first;
      for (auto np : edges[v]) {
        int nv = np.second;
        int ncost = np.first;
        q.push({cost - ncost, {nv, v}});
      }
    }
  }
  int ans = M;
  for (int i = 0; i < 100; i++) {
    for (int j = i + 1; j < 100; j++) {
      if (counts[{i, j}] > 0) {
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
