#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int main() {
  int n, m, MAX = 99999999;
  n;
  cin >> n;
  m;
  cin >> m;
  int a[n], b[n], c[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] -= 1;
    b[i] -= 1;
  }
  int dist[n][n];
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (n); (j)++) {
      dist[i][j] = MAX;
    }
    dist[i][i] = 0;
  }
  for (int(i) = 0; (i) < (m); (i)++) {
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(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 result = 0;
  for (int(i) = 0; (i) < (m); (i)++) {
    if (dist[a[i]][b[i]] < c[i]) {
      result += 1;
    }
  }
  result;
  cout << result << endl;
}
