#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int field[105][105];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      field[i][j] = (1e9);
    }
    field[i][i] = 0;
  }
  int a[1005], b[1005], c[1005];
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    field[a[i]][b[i]] = c[i];
    field[b[i]][a[i]] = c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        field[j][k] = min(field[j][k], field[j][i] + field[i][k]);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (field[a[i]][b[i]] < c[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
