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