#include <iostream>
#include <vector>
#include <queue>
#include <limits>
#include <forward_list>

using namespace std;

struct edge {
  int to, cost, id;
};

using graph = vector<vector<edge>>;
auto dijkstra(graph const& gr, int start) {
  int const V = gr.size();
  constexpr int Inf = numeric_limits<int>::max() / 2;
  vector<pair<int, forward_list<int>>> result(V, {Inf, forward_list<int>()}); 
  using P = pair<int, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  que.emplace(0, start);
  result[start].first = 0;
  while (!que.empty()) {
    int v, d;
    tie(d, v) = que.top();
    que.pop();
    if (d > result[v].first) continue;
    for (auto&& e : gr[v]) {
      if (result[e.to].first < d + e.cost) continue;
      if (result[e.to].first > d + e.cost)
        result[e.to].second.clear();
      result[e.to].first = d + e.cost;
      result[e.to].second.push_front(e.id);
      que.emplace(d + e.cost, e.to);
    }
  }
  return result;
}

int main() {
  int n, m;
  cin >> n >> m;
  graph gr(n);
  for (int i = 0; i < m; i++) {
    int a, b, cost;
    cin >> a >> b >> cost;
    a--; b--;
    gr[a].push_back({b, cost, i});
    gr[b].push_back({a, cost, i});
  }
  vector<bool> used(m, false);
  for (int i = 0; i < n; i++) {
    auto const& ds = dijkstra(gr, i);
    for (auto& v : ds)
      for (auto k : v.second)
        used[k] = true;
  }
  cout << count(begin(used), end(used), false) << endl;
}
