#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > dist(n, vector<int>(n, INFINITY));
  vector<int> A, B, C;
  for (int i = 0; i < n; i++) dist[i][i] = 0;
  for (int i = 0; i < m; i++) {
    int l, r, c;
    cin >> l >> r >> c;
    A.push_back(l - 1);
    B.push_back(r - 1);
    C.push_back(c);
    dist[A[i]][B[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]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (dist[A[i]][B[i]] < C[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
