#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 0;
vector<int> a, b, c;
vector<vector<int>> dist;
vector<bool> seen;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  a.resize(n);
  b.resize(n);
  c.resize(n);
  dist.resize(n);
  seen.resize(n);
  for (int i = 0, i_len = (n); i < i_len; i++) {
    dist[i].resize(n, 1e9);
    dist[i][i] = 0;
  }
  for (int i = 0, i_len = (m); i < i_len; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 0, i_len = (m); i < i_len; i++) {
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  for (int i = 0, i_len = (n); i < i_len; i++) {
    for (int ii = 0, ii_len = (n); ii < ii_len; ii++) {
      for (int iii = 0, iii_len = (n); iii < iii_len; iii++) {
        dist[ii][iii] = min(dist[ii][iii], dist[ii][i] + dist[i][iii]);
      }
    }
  }
  for (int i = 0, i_len = (m); i < i_len; i++) {
    if (dist[a[i]][b[i]] != c[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
