#include <bits/stdc++.h>
const int INF = 1e9 + 7;
using namespace std;
int d[100][100];
int V;
int main() {
  scanf("%d", &V);
  int v = V + 1, e, a[1000], b[1000], c[1000], ans = 0;
  for (int i = (0); i < (v); ++i) d[i][i] = 0;
  for (int i = (1); i < (v); ++i)
    for (int j = (1); j < (v); ++j) d[i][j] = INF;
  scanf("%d", &e);
  for (int i = (0); i < (e); ++i) scanf("%d%d%d", a + i, b + i, c + i);
  for (int i = (0); i < (e); ++i) d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  for (int k = (1); k < (v); ++k)
    for (int i = (1); i < (v); ++i)
      for (int j = (1); j < (v); ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  bool used;
  for (int i = (0); i < (e); ++i) {
    used = true;
    for (int s = (1); s < (v); ++s)
      if (d[s][a[i]] + c[i] == d[s][b[i]]) used = false;
    if (used) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
