#include <bits/stdc++.h>
using namespace std;
int dist[105][105];
int a[1005], b[1005], c[1005];
int n, m;
int main() {
  memset(dist, 0x3f, sizeof dist);
  scanf("%d%d", &n, &m);
  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++)
      for (int j = 1; j <= n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  int ans = m;
  for (int i = 1; i <= m; i++) {
    bool flag = false;
    for (int s = 1; s <= n; s++)
      if (dist[s][b[i]] == dist[s][a[i]] + c[i]) {
        flag = true;
        break;
      }
    if (flag) ans--;
  }
  printf("%d\n", ans);
}
