#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, pair<int, int>>>> r(
      n, vector<pair<int, pair<int, int>>>());
  vector<vector<int>> l(n, vector<int>(n, INT_MAX));
  vector<int> u(m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    r.at(--a).push_back({--b, {c, i}});
    r.at(b).push_back({a, {c, i}});
  }
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      que;
  for (int i = 0; i < n; i++) {
    que.push(pair<int, pair<int, int>>(i, pair<int, int>(0, -1)));
    l.at(i).at(i) = 0;
    while (que.size()) {
      pair<int, pair<int, int>> p = que.top();
      que.pop();
      if (l.at(i).at(p.first) < p.second.first) continue;
      if (p.second.second >= 0) u.at(p.second.second) = 1;
      for (auto e : r.at(p.first)) {
        if (l.at(i).at(e.first) > p.second.first + e.second.first) {
          que.push(pair<int, pair<int, int>>(
              e.first, pair<int, int>(p.second.first + e.second.first,
                                      e.second.second)));
          l.at(i).at(e.first) = p.second.first + e.second.first;
        }
      }
    }
  }
  int o = 0;
  for (int i = 0; i < m; i++) o += u[i];
  cout << m - o << endl;
}
