#include <bits/stdc++.h>
int const infty = 1000000007;
int d[101][101];
int a[1000], b[1000], c[1000];
int main() {
  int n, m, i, j, k, ans = 0;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) d[i][j] = infty;
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        if (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
  for (i = 0; i < m; i++) {
    bool flag = false;
    for (j = 1; j <= n; j++)
      if (d[j][a[i]] + c[i] == d[j][b[i]]) flag = true;
    if (!flag) ans++;
  }
  printf("%d", ans);
  return 0;
}
