#include <bits/stdc++.h>
int main() {
  int cnt = 0, s, goal, k, n, m, a[1000] = {}, b[1000] = {}, c[1000] = {},
      g[100][100] = {}, gs[100][100] = {};
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    g[a[i] - 1][b[i] - 1] = g[b[i] - 1][a[i] - 1] = gs[a[i] - 1][b[i] - 1] =
        gs[b[i] - 1][a[i] - 1] = c[i];
  }
  for (s = 0; s < n; s++) {
    for (goal = 0; goal < n; goal++) {
      for (k = 0; k < n; k++) {
        if (g[s][goal] > g[s][k] + g[k][goal])
          g[s][goal] = g[s][k] + g[k][goal];
      }
    }
  }
  for (int i = 0; i < n * n; i++) {
    s = i / n;
    goal = i % n;
    if (g[s][goal] < gs[s][goal]) cnt++;
  }
  printf("%d\n", cnt / 2);
  return 0;
}
