#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 110;
const int INF = 1e8;
int d[MAX_N][MAX_N];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) d[i][j] = 0;
    }
  }
  int a[M], b[M], c[M];
  for (int i = 0; i < 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 < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (d[i][k] + d[k][j] <= d[i][j]) {
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (d[a[i]][b[i]] != c[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}
