#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, i, j, co[110];
  bool u[110] = {false};
  vector<pair<int, int>> g[110];
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b >> co[i];
    g[a].push_back(pair<int, int>(b, i));
    g[b].push_back(pair<int, int>(a, i));
  }
  const int INF = 1e9;
  for (i = 1; i < n; i++) {
    int d[110], from[110];
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        pque;
    pque.push(pair<int, int>(0, i));
    for (j = 1; j <= n; j++) d[j] = INF;
    d[i] = 0;
    while (!pque.empty()) {
      pair<int, int> y = pque.top();
      pque.pop();
      int ds = y.first, is = y.second;
      if (d[is] < ds) continue;
      for (j = 0; j < g[is].size(); j++) {
        int ne = g[is][j].first;
        if (d[ne] > d[is] + co[g[is][j].second]) {
          d[ne] = d[is] + co[g[is][j].second];
          from[ne] = g[is][j].second;
          pque.push(pair<int, int>(d[ne], ne));
        }
      }
    }
    for (j = 1; j <= n; j++)
      if (j != i) u[from[j]] = true;
  }
  int ans = 0;
  for (i = 0; i < m; i++)
    if (!u[i]) ans++;
  cout << ans << endl;
  return 0;
}
