#include <bits/stdc++.h>
int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}
int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}
int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}
int main(void) {
  int vs, es;
  get_int2(&vs, &es);
  static int graph[100][100];
  int i;
  for (i = 0; i < es; i++) {
    int v1, v2, cost;
    get_int3(&v1, &v2, &cost);
    v1--;
    v2--;
    graph[v1][v2] = graph[v2][v1] = cost;
  }
  static int origin[100][100];
  memcpy(origin, graph, sizeof(int) * 100 * 100);
  int j, k;
  for (k = 0; k < vs; k++) {
    for (i = 0; i < vs; i++) {
      for (j = 0; j < vs; j++) {
        graph[i][j] = ((graph[i][j]) > (graph[i][k] + graph[k][j])
                           ? (graph[i][k] + graph[k][j])
                           : (graph[i][j]));
      }
    }
  }
  int cnt = 0;
  for (i = 0; i < vs; i++) {
    for (j = i + 1; j < vs; j++) {
      if (!origin[i][j]) continue;
      if (origin[i][j] != graph[i][j]) cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
