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