#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> dis(n, vector<int>(n, 1e9));
  vector<int> s(m), d(m), l(m);
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> d[i] >> l[i];
    s[i]--, d[i]--, l[i]--;
    dis[s[i]][d[i]] = l[i];
    dis[d[i]][s[i]] = l[i];
  }
  for (int i = 0; i < n; i++) dis[i][i] = 0;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dis[i][j] > dis[i][k] + dis[k][j]) {
          dis[i][j] = dis[i][k] + dis[k][j];
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (l[i] != dis[s[i]][d[i]]) ans++;
  }
  cout << ans << '\n';
}
