#include <vector>
#include <iostream>

using namespace std;

int INF = 1 << 20;

int main() {
  int N, M;

  cin >> N >> M;

  vector<int> a(M), b(M), c(M);

  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] -= 1;
    b[i] -= 1;
  }

  vector<vector<int>> dist(N, vector<int>(N, INF));

  for (int i = 0; i < N; i++) {
    dist[i][i] = 0;
  }

  for (int i = 0; i < M; i++) {
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (dist[a[i]][b[i]] < c[i]) {
      ans += 1;
    }
  }

  cout << ans << endl;
}