#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > a(n, vector<int>(n, 1e+9));
  vector<vector<int> > b(n, vector<int>(n, 0));
  for (long long int i = 0; i < m; ++i) {
    int s, t, u;
    cin >> s >> t >> u;
    s--;
    t--;
    a[s][t] = u;
    a[t][s] = u;
    b[s][t] = u;
    b[t][s] = u;
  }
  for (int i = 0; i < n; i++) {
    a[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (b[i][j] > 0) {
        if (a[i][j] != b[i][j]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
