#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
int main() {
  int N = in(), M = in();
  vi a(M), b(M), c(M);
  for (int e = 0; e < M; e++) {
    a[e] = in() - 1;
    b[e] = in() - 1;
    c[e] = in() - 1;
  }
  vvi dist(N, vi(N, (INT_MAX / 2)));
  for (int v = 0; v < N; v++) dist[v][v] = 0;
  for (int e = 0; e < M; e++) {
    dist[a[e]][b[e]] = min(dist[a[e]][b[e]], c[e]);
    dist[b[e]][a[e]] = min(dist[b[e]][a[e]], c[e]);
  }
  for (int r = 0; r < N; r++)
    for (int s = 0; s < N; s++)
      for (int t = 0; t < N; t++)
        dist[s][t] = min(dist[s][t], dist[s][r] + dist[r][t]);
  int ans = 0;
  for (int e = 0; e < M; e++)
    if (dist[a[e]][b[e]] < c[e]) ans++;
  cout << ans << endl;
}
