#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<bool> used;
vector<vector<tuple<long long, int, int> > > r;
long long getCost(tuple<long long, int, int> info) { return get<0>(info); }
int getTo(tuple<long long, int, int> info) { return get<1>(info); }
int getNo(tuple<long long, int, int> info) { return get<2>(info); }
void Dijkstra(int start) {
  priority_queue<tuple<long long, int, int>,
                 vector<tuple<long long, int, int> >,
                 greater<tuple<long long, int, int> > >
      q;
  set<int> s;
  s.insert(start);
  for (auto&& i : r[start]) {
    q.push(i);
  }
  while (q.size()) {
    int to = getTo(q.top());
    if (s.count(to)) {
      q.pop();
      continue;
    }
    s.insert(to);
    long long cost = getCost(q.top());
    used[getNo(q.top())] = true;
    q.pop();
    for (auto&& i : r[to]) {
      if (s.count(getTo(i))) continue;
      q.push(make_tuple(cost + getCost(i), getTo(i), getNo(i)));
    }
  }
}
void hawawa() {
  cin >> n >> m;
  r.resize(n);
  used.resize(m, false);
  for (int i = 0; i < m; i++) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    a--;
    b--;
    r[a].push_back(make_tuple(c, b, i));
    r[b].push_back(make_tuple(c, a, i));
  }
  for (int i = 0; i < n; i++) {
    Dijkstra(i);
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (!used[i]) ans++;
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
  return 0;
}
