#include <bits/stdc++.h>
int main() {
  int n, m, a, b, c, i, j, k, s = 0, d[110][110], f[110][110], e[110][110] = {};
  int u[110] = {};
  scanf("%d %d", &n, &m);
  for (i = 0; i < n * n; i++) d[i / n][i % n] = 1e9;
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &a, &b, &c);
    a--;
    b--;
    d[a][b] = d[b][a] = c;
    e[a][b] = e[b][a] = i;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < n; k++) {
        if (d[j][k] > d[j][i] + d[i][k]) {
          d[j][k] = d[j][i] + d[i][k];
          f[j][k] = f[i][k];
          s += 1 - u[e[i][k]];
          u[e[i][k]] = 1;
        }
      }
    }
  }
  printf("%d\n", m - s);
  return 0;
}
