#include <bits/stdc++.h>
using namespace std;
int N, M, A[1100], B[1100], C[1100], dist[101][101], INF = 1 << 27;
void solve() {
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    for (int(j) = (0); (j) < (int)(N); ++(j)) dist[i][j] = INF;
    dist[i][i] = 0;
  }
  for (int(i) = (0); (i) < (int)(M); ++(i))
    dist[A[i]][B[i]] = dist[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))
        (dist[i][j]) = min((dist[i][j]), (dist[i][k] + dist[k][j]));
  int ans = M;
  for (int(e) = (0); (e) < (int)(M); ++(e)) {
    int j = A[e], k = B[e], d = C[e], use = 0;
    for (int(i) = (0); (i) < (int)(N); ++(i))
      for (int(l) = (0); (l) < (int)(N); ++(l)) {
        if (dist[i][j] + d + dist[k][l] == dist[i][l]) {
          use = 1;
          goto END;
        }
      }
  END:;
    ans -= use;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (cin >> N >> M) {
    for (int(i) = (0); (i) < (int)(M); ++(i))
      cin >> A[i] >> B[i] >> C[i], --A[i], --B[i];
    solve();
  }
}
