#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, a[1100], b[1100], c[1100], d[110][110], inf = 1 << 30;
  cin >> n >> m;
  for (int i = 0; i < 110; i++) {
    for (int j = 0; j < 110; j++) d[i][j] = inf;
    d[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[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 = 0;
  for (int i = 0; i < m; i++) {
    if (d[a[i]][b[i]] < c[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
