#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> a(110), b(110), c(110);
int d[110][110];
int main() {
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      d[i][j] = 100000000;
    }
  }
  for (int i = 1; i <= M; i++) {
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= M; i++) {
    if (d[a[i]][b[i]] != c[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}
