#include <bits/stdc++.h>
using namespace std;
long long n, m, a, b, c;
long long d[110][110];
set<std::pair<long long, long long> > st;
signed main() {
  cin >> n >> m;
  for (long long(i) = 0; (i) < (110); (i)++) {
    for (long long(j) = 0; (j) < (110); (j)++) d[i][j] = LLONG_MAX / 3;
  }
  for (long long(i) = 0; (i) < (m); (i)++) {
    cin >> a >> b >> c;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (long long k = 1; k <= n; k++) {
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        if (d[i][j] >= d[i][k] + d[k][j]) {
          st.insert({i, k});
          st.insert({k, i});
          st.insert({k, j});
          st.insert({j, k});
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  cout << m - st.size() / 2 << endl;
  return 0;
}
