#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n, m, ans = 0;
bool ok;
vector<long long> g[1005];
map<pair<long long, long long>, long long> mp;
long long u[1005], v[1005], c[1005];
void dfs(long long pre, long long u, long long v, long long c, long long cnt) {
  if (cnt >= c) return;
  if (u == v && cnt < c) {
    ok = true;
    return;
  }
  for (auto &it : g[u]) {
    if (it != pre) dfs(u, it, v, c, cnt + mp[{u, it}]);
  }
}
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> u[i] >> v[i] >> c[i];
    g[u[i]].push_back(v[i]);
    g[v[i]].push_back(u[i]);
    if (mp[{u[i], v[i]}])
      mp[{v[i], u[i]}] = mp[{v[i], u[i]}] = min(c[i], mp[{u[i], v[i]}]);
    else
      mp[{u[i], v[i]}] = mp[{v[i], u[i]}] = c[i];
  }
  for (long long i = 0; i < m; i++) {
    ok = false;
    if (mp[{u[i], v[i]}] < c[i])
      ok = true;
    else
      dfs(0, u[i], v[i], c[i], 0);
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
