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