#include <bits/stdc++.h>
using namespace std;
const int inf = 1e7;
struct dat {
  int at, cost, from;
  dat() { at = cost = from = -1; }
  dat(int a, int b, int c) : at(a), cost(b), from(c) {}
};
signed main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> G(n, vector<int>(n, inf));
  vector<vector<bool>> H(n, vector<bool>(n, false));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    G[a][b] = G[b][a] = c;
  }
  auto f = [](dat a, dat b) { return a.cost > b.cost; };
  for (int src = 0; src < n - 1; ++src) {
    for (int dst = src + 1; dst < n; ++dst) {
      priority_queue<dat, vector<dat>, decltype(f)> que(f);
      que.push(dat(src, 0, -1));
      while (!que.empty()) {
        dat q = que.top();
        que.pop();
        if (q.from != -1) H[q.at][q.from] = H[q.from][q.at] = true;
        if (q.at == dst) break;
        for (int i = 0; i < n; ++i) {
          if (i == q.at || i == q.from) continue;
          if (G[q.at][i] < inf) que.push(dat(i, G[q.at][i] + q.cost, q.at));
        }
      }
    }
  }
  int r = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (H[i][j]) ++r;
    }
  }
  cout << m - r;
}
