#include <bits/stdc++.h>
int d[1005][1005], be[1005][1005];
int V, E;
void floyd() {
  for (int k = 1; k <= V; k++)
    for (int i = 1; i <= V; i++)
      for (int j = 1; j <= V; j++)
        if (d[i][j] > std::min(d[i][k], d[k][j])) d[i][j] = d[i][k] + d[k][j];
}
int main() {
  int a, b, c, cnt = 0;
  scanf("%d %d", &V, &E);
  for (int i = 1; i <= V; i++) {
    for (int j = 1; j <= V; j++) {
      if (i == j) {
        d[i][j] = 0;
        be[i][j] = 0;
      } else {
        d[i][j] = 999999;
        be[i][j] = 999999;
      }
    }
  }
  for (int i = 0; i < E; i++) {
    scanf("%d %d %d", &a, &b, &c);
    d[a][b] = c;
    d[b][a] = c;
    be[a][b] = c;
    be[b][a] = c;
  }
  floyd();
  for (int i = 1; i <= V; i++)
    for (int j = i + 1; j <= V; j++)
      if (be[i][j] != 999999 && d[i][j] != be[i][j]) cnt++;
  printf("%d\n", cnt);
  return 0;
}
