#include <bits/stdc++.h>
int main() {
  int n, m, distance[100][100]{}, edge[100][100]{};
  std::fill(distance[0], distance[0] + 10000, 100000000);
  std::fill(edge[0], edge[0] + 10000, 100000000);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--;
    b--;
    distance[a][b] = distance[b][a] = edge[a][b] = edge[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    distance[i][i] = edge[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        distance[i][j] =
            std::min(distance[i][j], distance[i][k] + distance[k][j]);
      }
    }
  }
  int count{};
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (edge[i][j] != 100000000 && edge[i][j] != distance[i][j]) count++;
    }
  }
  printf("%d\n", count);
  return 0;
}
