#include <bits/stdc++.h>
int main() {
  int g[128][128] = {};
  for (size_t i = 0; i < 128; ++i)
    for (size_t j = 0; j < 128; ++j)
      if (i != j) g[i][j] = 5e8;
  size_t N;
  int M;
  scanf("%zu %d", &N, &M);
  std::map<std::pair<size_t, size_t>, int> edges;
  std::vector<std::pair<size_t, size_t>> orig;
  for (int i = 0; i < M; ++i) {
    size_t a, b;
    int c;
    scanf("%zu %zu %d", &a, &b, &c);
    --a, --b;
    g[a][b] = g[b][a] = c;
    edges[std::make_pair(a, b)] = 1;
    edges[std::make_pair(b, a)] = 1;
    if (a > b) std::swap(a, b);
    orig.emplace_back(a, b);
  }
  for (size_t k = 0; k < N; ++k)
    for (size_t i = 0; i < N; ++i)
      for (size_t j = 0; j < N; ++j)
        if (g[i][j] > g[i][k] + g[k][j]) {
          g[i][j] = g[i][k] + g[k][j];
          if (edges[std::make_pair(i, j)] > 0) --edges[std::make_pair(i, j)];
          ++edges[std::make_pair(i, k)];
          ++edges[std::make_pair(k, j)];
        }
  int cnt = 0;
  for (const auto &e : orig)
    if (!edges[e] && !edges[std::make_pair(e.second, e.first)]) ++cnt;
  printf("%d\n", cnt);
  return 0;
}
