#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  std::cin >> n >> m;
  vector<vector<pair<int, int> > > g(n);
  set<pair<int, int> > s;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    std::cin >> a >> b >> c;
    a--, b--;
    g[a].push_back(pair<int, int>(b, c));
    g[b].push_back(pair<int, int>(a, c));
  }
  for (int i = 0; i < n; ++i) sort(g[i].begin(), g[i].end());
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  for (int i = 0; i < n; i++) {
    vector<int> cost(n, 1e9);
    vector<int> parent(n, -1);
    que.push(pair<int, int>(0, i));
    while (not que.empty()) {
      int v = que.top().second;
      int c = que.top().first;
      que.pop();
      for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i].first;
        if (cost[to] > c + g[v][i].second) {
          cost[to] = c + g[v][i].second;
          que.push(pair<int, int>(cost[to], to));
          parent[to] = v;
        }
      }
    }
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      s.insert(pair<int, int>(j, parent[j]));
      s.insert(pair<int, int>(parent[j], j));
    }
  }
  std::cout << m - s.size() / 2 << std::endl;
  return 0;
}
