#include <bits/stdc++.h>
long path[401][401];
void init() {
  long i, j;
  for (i = 1; i <= 400; i++) {
    for (j = 1; j <= 400; j++) {
      if (i == j) {
        path[i][j] = 0;
      } else {
        path[i][j] = 100000000000;
      }
    }
  }
}
int main() {
  long N, M;
  long a[1001], b[1001], c[1001];
  long i, j, k;
  long tmp;
  long ans;
  init();
  scanf("%ld", &N);
  scanf("%ld", &M);
  ans = M;
  for (i = 1; i <= M; i++) {
    scanf("%ld", &a[i]);
    scanf("%ld", &b[i]);
    scanf("%ld", &c[i]);
    path[a[i]][b[i]] =
        (((path[a[i]][b[i]]) < (c[i])) ? (path[a[i]][b[i]]) : (c[i]));
    path[b[i]][a[i]] =
        (((path[b[i]][a[i]]) < (c[i])) ? (path[b[i]][a[i]]) : (c[i]));
  }
  for (i = 1; i <= N; i++)
    for (j = 1; j <= N; j++)
      for (k = 1; k <= N; k++)
        path[j][k] = (((path[j][k]) < (path[j][i] + path[i][k]))
                          ? (path[j][k])
                          : (path[j][i] + path[i][k]));
  for (k = 1; k <= M; k++) {
    for (i = 1; i < N; i++) {
      if (path[i][a[k]] + c[k] == path[i][b[k]]) {
        ans--;
        break;
      }
    }
  }
  printf("%ld\n", ans);
  return 0;
}
