#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pint>>;
int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  set<pint> route;
  for (ll i = 0; i < (ll)(M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  for (ll s = 0; s < (ll)(N); s++) {
    vector<int> dist(N, -1);
    priority_queue<pint, vector<pint>, greater<pint>> Q;
    dist[s] = 0;
    Q.push({0, s});
    while (!Q.empty()) {
      int v = Q.top().first;
      Q.pop();
      for (auto p : G[v]) {
        int nv = p.first, cost = p.second;
        if (dist[nv] != -1) continue;
        dist[nv] = dist[v] + cost;
        Q.push({dist[nv], nv});
        route.insert({v, nv});
        route.insert({nv, v});
      }
    }
  }
  cout << M - route.size() / 2 << endl;
}
