#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  int a[M], b[M], c[M];
  for (int i = 0; i < (M); i++) cin >> a[i] >> b[i] >> c[i];
  int d[N][N];
  for (int i = 0; i < (N); i++)
    for (int j = 0; j < (N); j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = numeric_limits<int>::max();
    }
  for (int i = 0; i < (M); i++) {
    d[a[i]][b[i]] = c[i];
    d[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++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int ans = M;
  for (int i = 0; i < M; ++i) {
    bool shortest = false;
    for (int j = 0; j < N; ++j)
      if (d[j][a[i]] + c[i] == d[j][b[i]]) shortest = true;
    if (shortest == true) {
      ans = ans - 1;
    }
  }
  cout << ans << '\n';
}
