#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int>;
using P = pair<int, int>;
const int INF = 100000000;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> adj_list[N];
  map<P, int> weight;
  for (int i = 0; i < (M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    adj_list[a].push_back(b);
    adj_list[b].push_back(a);
    weight[make_pair(a, b)] = c;
    weight[make_pair(b, a)] = c;
  }
  set<P> used;
  for (int i = 0; i < (M); i++) {
    int distance[N];
    for (int j = 0; j < (N); j++) distance[j] = -1;
    distance[i] = 0;
    priority_queue<T, vector<T>, greater<T>> pque;
    pque.push(make_tuple(0, i, -1));
    while (pque.size() > 0) {
      T elem = pque.top();
      pque.pop();
      int d, now, before;
      tie(d, now, before) = elem;
      if (before == -1) {
      } else if (distance[now] == -1 or d == distance[now]) {
        distance[now] = d;
        used.insert(make_pair(now, before));
        used.insert(make_pair(before, now));
      } else
        continue;
      for (auto next : adj_list[now]) {
        pque.push(make_tuple(d + weight[make_pair(now, next)], next, now));
      }
    }
  }
  int ans = M - used.size() / 2;
  cout << ans << endl;
  return 0;
}
