#include <bits/stdc++.h>
int dis[105][105], path1[1005], path2[1005], value[1005];
int main() {
  int n, m, i, j, k, a, b;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &j);
    dis[a][b] = dis[b][a] = j;
    path1[i] = a;
    path2[i] = b;
    value[i] = j;
  }
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        if (dis[i][k] + dis[k][j] < dis[i][j])
          dis[i][j] = dis[i][k] + dis[k][j];
  int sum = 0;
  for (i = 0; i < m; i++)
    if (dis[path1[i]][path2[i]] < value[i]) sum++;
  printf("%d", sum);
}
