#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};
int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> a(N), b(N), c(N);
  vector<pair<int, int>> tonari[100];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    tonari[a[i] - 1].push_back({b[i] - 1, c[i]});
    tonari[b[i] - 1].push_back({a[i] - 1, c[i]});
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int start = a[i] - 1, goal = b[i] - 1;
    vector<bool> det(N, false);
    vector<int> sdis(N, 1e9);
    priority_queue<int, vector<int>, greater<int>> pq;
    sdis[start] = 0;
    pq.push(start);
    while (!pq.empty()) {
      int pos = pq.top();
      pq.pop();
      if (det[pos]) break;
      det[pos] = true;
      for (auto j : tonari[pos]) {
        if (det[j.first]) continue;
        sdis[j.first] = min(sdis[j.first], sdis[pos] + j.second);
        pq.push(j.first);
      }
    }
    if (sdis[goal] < c[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
