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