#include <bits/stdc++.h>
using namespace std;
static int32_t a[1000];
static int32_t b[1000];
static int32_t edges[100][100];
static int32_t dists[100][100];
int32_t main() {
  uint32_t N, M;
  cin >> N >> M;
  for (uint32_t i = 0; i < M; i++) {
    uint32_t a_, b_, c_;
    cin >> a_ >> b_ >> c_;
    a[i] = a_ - 1;
    b[i] = b_ - 1;
    edges[a_ - 1][b_ - 1] = dists[a_ - 1][b_ - 1] = c_;
    edges[b_ - 1][a_ - 1] = dists[b_ - 1][a_ - 1] = c_;
  }
  for (uint32_t k = 0; k < N; k++) {
    for (uint32_t i = 0; i < N; i++) {
      for (uint32_t j = 0; j < N; j++) {
        if ((dists[i][k] == 0) || (dists[k][j] == 0)) continue;
        int32_t dist = dists[i][k] + dists[k][j];
        if (dist < dists[i][j]) {
          dists[i][j] = dist;
        }
      }
    }
  }
  uint32_t count = 0;
  for (uint32_t _ = 0; _ < M; _++) {
    uint32_t i = a[_];
    uint32_t j = b[_];
    bool contained = false;
    for (uint32_t s = 0; s < N; s++) {
      for (uint32_t t = 0; t < N; t++) {
        if (dists[s][t] == dists[s][i] + edges[i][j] + dists[j][t]) {
          contained = true;
        }
      }
    }
    if (!contained) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
