#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int main() {
  int d[100][100];
  int e[1000][3];
  int i, j, k, l, m, n;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) d[i][j] = 1000000000 * (i != j);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &j, &k, &l);
    e[i][0] = j - 1;
    e[i][1] = k - 1;
    d[k - 1][j - 1] = d[j - 1][k - 1] = e[i][2] = l;
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      for (k = 0; k < n; k++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  j = 0;
  for (i = 0; i < m; i++) j += d[e[i][0]][e[i][1]] < e[i][2];
  printf("%d", j);
}
