#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const long long MOD = 1e9 + 7;
long long N, M;
long long d[101][101];
long long a[1001], b[1001], c[1001];
set<pair<long long, long long> > st;
int main() {
  cin >> N >> M;
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < N; j++) d[i][j] = INF;
  for (long long i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
  }
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < M; i++) {
    if (d[a[i]][b[i]] < c[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
