#include <bits/stdc++.h>
struct Neighborhood {
  int dist;
  int no;
};
int main() {
  int i, j;
  int N, M;
  scanf("%d %d", &N, &M);
  int a[M + 1], b[M + 1], c[M + 1];
  for (i = 1; i <= M; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]);
  int dist[N + 1][N + 1];
  for (j = 1; j <= N; j++) {
    for (i = 1; i <= N; i++) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = 9999999;
      }
    }
  }
  struct Neighborhood nbh[N + 1][N + 1];
  for (i = 1; i <= M; i++) {
    nbh[a[i]][b[i]].dist = c[i];
    nbh[b[i]][a[i]].dist = c[i];
    nbh[a[i]][b[i]].no = i;
    nbh[b[i]][a[i]].no = i;
  }
  int s;
  int t;
  int from[N + 1];
  int fix[N + 1];
  int temp_min;
  int min_edge;
  int cnt;
  int use[M + 1];
  for (s = 1; s < N; s++) {
    for (i = 1; i <= N; i++) fix[i] = 0;
    fix[s] = 1;
    t = s;
    for (cnt = 1; cnt < N; cnt++) {
      for (i = 1; i <= N; i++) {
        if (nbh[t][i].dist && !fix[i]) {
          dist[s][i] = dist[s][t] + nbh[t][i].dist;
          from[i] = nbh[t][i].no;
        }
      }
      temp_min = 9999;
      for (i = 1; i <= N; i++) {
        if (!fix[i] && dist[s][i] < temp_min) {
          temp_min = dist[s][i];
          min_edge = i;
        }
      }
      fix[min_edge] = 1;
      t = min_edge;
    }
    for (i = 1; i <= N; i++) use[from[i]] = 1;
  }
  int ans = 0;
  for (i = 1; i <= M; i++) {
    if (!use[i]) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
