#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > vec(n, vector<int>(n, 1e8));
  vector<int> a(m), b(m), c(m);
  for (int i = 0; m > i; i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    vec[a[i]][b[i]] = vec[b[i]][a[i]] = c[i];
  }
  for (int k = 0; n > k; k++) {
    for (int i = 0; n > i; i++) {
      for (int j = 0; n > j; j++) {
        if (vec[i][k] == 1e8 or vec[k][j] == 1e8) {
          continue;
        }
        vec[i][j] = min(vec[i][j], vec[i][k] + vec[k][j]);
      }
    }
  }
  int say = 0;
  for (int i = 0; m > i; i++) {
    bool use = false;
    for (int j = 0; n > j; j++) {
      if (vec[j][b[i]] == vec[j][a[i]] + c[i]) {
        use = true;
      }
    }
    if (use) {
      say++;
    }
  }
  cout << m - say;
}
