#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a[110], b[110], c[110][110] = {}, d[110][110] = {}, ans = 0;
  cin >> n >> m;
  for (int i = 0; i++ < n;)
    for (int j = 0; j++ < n;)
      if (i != j) d[i][j] = 10000;
  for (int i = 0; i++ < m;) {
    cin >> a[i] >> b[i];
    cin >> c[a[i]][b[i]];
    c[b[i]][a[i]] = c[a[i]][b[i]];
    d[a[i]][b[i]] = c[a[i]][b[i]];
    d[b[i]][a[i]] = c[a[i]][b[i]];
  }
  for (int k = 0; k++ < n;)
    for (int i = 0; i++ < n;)
      for (int j = 0; j++ < n;) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  for (int i = 0; i++ < m;)
    if (c[a[i]][b[i]] > d[a[i]][b[i]]) ans++;
  cout << ans << endl;
}
