#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  long long int N, M;
  cin >> N >> M;
  vector<bool> used(M);
  using Tuple = tuple<long long int, long long int, long long int>;
  vector<vector<Tuple>> nbr(N);
  for (long long int i = 0; i < M; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    nbr.at(a).emplace_back(b, c, i);
    nbr.at(b).emplace_back(a, c, i);
  }
  long long int big = 1000 * 1000;
  for (long long int i = 0; i < N; i++) {
    priority_queue<Tuple, vector<Tuple>, greater<Tuple>> pq;
    vector<long long int> dist(N, big);
    pq.emplace(i, 0, -1);
    dist.at(i) = 0;
    while (!pq.empty()) {
      long long int j, c, k;
      tie(j, c, k) = pq.top();
      pq.pop();
      if (dist.at(j) < c) continue;
      if (k >= 0) used.at(k) = true;
      for (Tuple t : nbr.at(j)) {
        long long int j1, c1, k1;
        tie(j1, c1, k1) = t;
        if (dist.at(j1) < dist.at(j) + c1) continue;
        dist.at(j1) = dist.at(j) + c1;
        pq.emplace(j1, dist.at(j) + c1, k1);
      }
    }
  }
  long long int cnt = 0;
  for (long long int i = 0; i < M; i++)
    if (!used.at(i)) cnt++;
  cout << cnt << endl;
  return 0;
}
