#include <bits/stdc++.h>
const int MOD = 1000000007;
const int INF = 1001001001;
using namespace std;
struct Edge {
  int from, to, cost;
  Edge(int from_, int to_, int cost_) {
    from = from_;
    to = to_;
    cost = cost_;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> to(n);
  vector<Edge> e;
  int to_, from, cost;
  for (int i = 0; i < m; ++i) {
    cin >> from >> to_ >> cost;
    from--;
    to_--;
    to[from].emplace_back(cost, to_);
    to[to_].emplace_back(cost, from);
    e.emplace_back(from, to_, cost);
  }
  int ans = 0;
  for (auto edge : e) {
    int sn, sc;
    sn = edge.from;
    sc = edge.cost;
    vector<int> dp(n, INF);
    dp[sn] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        pq;
    pq.emplace(sc, sn);
    int cn, cc, nn, nc;
    while (!pq.empty()) {
      cn = pq.top().second;
      cc = pq.top().first;
      pq.pop();
      for (auto next : to[cn]) {
        nn = next.second;
        nc = next.first;
        if (dp[nn] > dp[cc] + nc) {
          dp[nn] = dp[cc] + nc;
          pq.emplace(dp[nn], nn);
        }
      }
    }
    if (dp[edge.to] < edge.cost) ans++;
  }
  cout << ans << endl;
  return 0;
}
