#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int from;
  int to;
  int length;
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<Edge> edges;
  for (int i = 0; i < M; ++i) {
    int f, t, l;
    cin >> f >> t >> l;
    edges.emplace_back(Edge{f - 1, t - 1, l});
  }
  const int kUnconnected = 100000000;
  vector<vector<int>> dists(N, vector<int>(N, kUnconnected));
  for (auto& e : edges) {
    dists[e.from][e.to] = e.length;
    dists[e.to][e.from] = e.length;
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j]);
      }
    }
  }
  int ret = 0;
  for (auto& e : edges) {
    bool used = false;
    for (int i = 0; i < N && !used; ++i) {
      if (i == e.from || i == e.to) continue;
      if (abs(dists[i][e.from] - dists[i][e.to]) == e.length) used = true;
    }
    if (!used) ++ret;
  }
  cout << ret << "\n";
  return 0;
}
