#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void) {
  int n, m, a, b, c, r[150][150] = {}, t[150][150] = {}, i, j, k;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b >> c;
    r[a - 1][b - 1] = c;
    r[b - 1][a - 1] = c;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      t[i][j] = r[i][j];
    }
  }
  for (k = 0; k < n; k++) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        r[i][j] = min(r[i][j], r[i][k] + r[k][j]);
      }
    }
  }
  int ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (r[i][j] != t[i][j]) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
}
