#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<pair<int, int>>> adj;
set<pair<int, int>> used;
void paths(int start) {
  vector<bool> visited(n);
  priority_queue<pair<int, pair<int, int>>> next;
  next.push({0, {start, -1}});
  while (!next.empty()) {
    int dist = -next.top().first;
    int node = next.top().second.first, parent = next.top().second.second;
    next.pop();
    if (visited[node]) continue;
    visited[node] = true;
    if (parent != -1) {
      used.insert({min(node, parent), max(node, parent)});
    }
    for (auto child : adj[node]) {
      next.push({-(dist + child.second), {child.first, node}});
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  adj.resize(n);
  used.clear();
  for (int i = 0; i < m; i++) {
    int u, v, weight;
    cin >> u >> v >> weight;
    u--;
    v--;
    adj[u].push_back({v, weight});
    adj[v].push_back({u, weight});
  }
  for (int i = 0; i < n; i++) {
    paths(i);
  }
  cout << m - used.size() << endl;
  return 0;
}
