#include <bits/stdc++.h>
using namespace std;
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;
    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;
        dists[i][j] = min(dists[i][k] + dists[k][j], dists[i][j]);
      }
    }
  }
  uint32_t count = M;
  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t j = i + 1; j < N; j++) {
      if (edges[i][j] == 0) continue;
      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;
}
