#include <bits/stdc++.h>
int main() {
  int g[128][128] = {}, d[128][128] = {};
  int inf = 5e8;
  for (size_t i = 0; i < 128; ++i)
    for (size_t j = 0; j < 128; ++j) g[i][j] = inf;
  size_t N;
  int M;
  scanf("%zu %d", &N, &M);
  std::vector<size_t> a(M), b(M);
  for (int i = 0; i < M; ++i) {
    int c;
    scanf("%zu %zu %d", &a[i], &b[i], &c);
    --a[i], --b[i];
    g[a[i]][b[i]] = g[b[i]][a[i]] = c;
  }
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j) d[i][j] = g[i][j];
  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 (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
  int cnt = 0;
  for (size_t i = 0; i < M; ++i) {
    size_t u = a[i], v = b[i];
    bool useful = false;
    for (size_t k = 0; k < N; ++k) {
      if (u == k || k == v) continue;
      if (g[u][v] <= d[u][k] + d[k][v]) {
        useful |= true;
        break;
      }
    }
    if (!useful) ++cnt;
  }
  printf("%d\n", cnt);
  return 0;
}
