#include <bits/stdc++.h>
using namespace std;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T> >;
long long n, m, d[110][110], a[101], b[101], c[101], ans;
int main(void) {
  cin >> n >> m;
  for (long long i = ((long long)(1)); i <= ((long long)(n)); i++)
    for (long long j = ((long long)(1)); j <= ((long long)(n)); j++)
      d[i][j] = 1e18;
  for (long long i = ((long long)(1)); i <= ((long long)(n)); i++) d[i][i] = 0;
  for (long long i = 0; i < ((long long)(m)); i++) {
    cin >> a[i] >> b[i] >> c[i];
    d[a[i]][b[i]] = min(c[i], d[a[i]][b[i]]);
    d[b[i]][a[i]] = min(c[i], d[b[i]][a[i]]);
  }
  for (long long i = ((long long)(1)); i <= ((long long)(n)); i++) {
    for (long long j = ((long long)(1)); j <= ((long long)(n)); j++) {
      for (long long k = ((long long)(1)); k <= ((long long)(n)); k++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  ans = m;
  for (long long i = 0; i < ((long long)(m)); i++) {
    if (c[i] == d[a[i]][b[i]]) ans--;
  }
  cout << ans << endl;
  return 0;
}
