#include <bits/stdc++.h>
using namespace std;
int x[106], y[106], z[106], n, m, ans, f[106][106];
int main() {
  scanf("%d%d", &n, &m);
  memset(f, 60, sizeof f);
  for (int i = 1; i <= n; i++) f[i][i] = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x[i], &y[i], &z[i]);
    f[x[i]][y[i]] = f[y[i]][x[i]] = z[i];
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      if (k != i)
        for (int j = 1; j <= n; j++)
          if (j != i && j != k && f[i][j] > f[i][k] + f[k][j])
            f[i][j] = f[i][k] + f[k][j];
  for (int i = 1; i <= m; i++)
    if (f[x[i]][y[i]] < z[i]) ans++;
  printf("%d\n", ans);
}
