#include <bits/stdc++.h>
int min(int n1, int n2) { return n1 < n2 ? n1 : n2; }
int d[100][100];
int main(void) {
  int i, j, k, N, M, a[1000], b[1000], c[1000], ans = 0;
  scanf("%d%d", &N, &M);
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      d[i][j] = 1 << 25;
    }
    d[i][i] = 0;
  }
  for (i = 0; i < M; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (k = 0; k < N; k++) {
    for (i = 0; i < N; i++) {
      for (j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (i = 0; i < M; i++) {
    if (d[a[i]][b[i]] < c[i]) {
      ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
