#include <bits/stdc++.h>
using namespace std;
int N, M;
int a[1005];
int b[1005];
int c[1005];
int dist[105][105];
int main() {
  int ans;
  cin >> N >> M;
  ans = M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) dist[i][j] = 0;
      dist[i][j] = 1000000000;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 0; i < M; i++) {
    bool check = 0;
    for (int j = 0; j < N; j++) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) check = 1;
    }
    if (check) ans--;
  }
  cout << ans << endl;
  return 0;
}
