#include <bits/stdc++.h>
using namespace std;
long long INF = (1ll << 32);
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> a(M), b(M), c(M);
  for (long long i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] -= 1;
    b[i] -= 1;
  }
  vector<vector<long long> > m(N, vector<long long>(N, INF));
  for (long long i = 0; i < N; i++) m[i][i] = 0;
  for (long long i = 0; i < M; i++) {
    m[a[i]][b[i]] = c[i];
    m[b[i]][a[i]] = c[i];
  }
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      for (long long k = 0; k < N; k++) {
        if (m[j][k] > m[j][i] + m[i][j]) {
          m[j][k] = m[j][i] = m[i][k];
        }
      }
    }
  }
  long long cnt = 0;
  for (long long i = 0; i < M; i++) {
    if (min(m[a[i]][b[i]], m[b[i]][a[i]]) < c[i]) {
      cnt += 1;
    }
  }
  cout << cnt << endl;
}
