#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long n, m;
vector<vector<long long> > g(n, vector<long long>(n, 0));
int main(void) {
  cin >> n >> m;
  vector<long long> a(m);
  vector<long long> b(m);
  vector<long long> c(m);
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (i != j) {
        g[i][j] = INFINITY;
      }
    }
  }
  for (long long i = 0; i < m; i++) {
    g[a[i]][b[i]] = min(g[a[i]][b[i]], c[i]);
    g[a[i]][b[i]] = g[a[i]][b[i]];
  }
  for (long long d = 0; d < n; d++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        g[i][j] = min(g[i][j], g[i][d] + g[d][j]);
      }
    }
  }
  long long ans = m;
  bool isShortest = false;
  for (long long i = 0; i < m; i++) {
    isShortest = false;
    for (long long j = 0; j < n; j++) {
      if (g[j][a[i]] + c[i] == g[j][b[i]]) {
        isShortest = true;
      }
    }
    if (isShortest) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
