#include <bits/stdc++.h>
using namespace std;
int dist[110][110];
int a[110], b[110], c[110];
int n, m;
int ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) dist[i][j] = 1e9;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", a + i, b + i, c + i);
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      if (i == k) continue;
      for (int j = 1; j <= n; j++) {
        if (i == j || k == j) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (dist[a[i]][b[i]] != c[i]) ans++;
  }
  printf("%d", ans);
  return 0;
}
