#include <bits/stdc++.h>
using namespace std;
int d[100][100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int N, M;
  cin >> N >> M;
  memset(d, (1 << 30), sizeof(d[0][0]) * 100 * 100);
  vector<int> a(M), b(M), c(M);
  for (int i = 0; i < (int)M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < (int)N; ++k) {
    for (int i = 0; i < (int)N; ++i) {
      for (int j = 0; j < (int)N; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = 0;
  for (int k = 0; k < (int)M; ++k) {
    if (d[a[k]][b[k]] != c[k]) ans++;
  }
  cout << ans << endl;
  return 0;
}
