#include <bits/stdc++.h>
int N, M;
int edge[110][110];
int vis[1100];
int last[110];
int L[110];
int vv[110];
int G[110][110];
int Eu[1100];
int Ev[1100];
int H[100100];
int H2[100100];
int Hn = 0;
void addHeap(int nd, int x) {
  Hn++;
  H[Hn] = x;
  H2[Hn] = nd;
  int i = Hn, j;
  while (i > 1) {
    j = i / 2;
    if (H[j] > x) {
      H[i] = H[j];
      H2[i] = H2[j];
      i = j;
    } else
      break;
  }
  H[i] = x;
  H2[i] = nd;
}
void delHeap(int &nd, int &x) {
  int r = H[1];
  int rnd = H2[1];
  int tmp = H[Hn];
  int t2 = H2[Hn];
  Hn--;
  int i = 1, j;
  while (2 * i <= Hn) {
    j = 2 * i;
    if (j + 1 <= Hn && H[j + 1] < H[j]) j++;
    if (H[j] < tmp) {
      H[i] = H[j];
      H2[i] = H2[j];
      i = j;
    } else
      break;
  }
  H[i] = tmp;
  H2[i] = t2;
  x = r;
  nd = rnd;
}
void calc(int s, int t) {
  int i;
  Hn = 0;
  addHeap(s, 0);
  last[s] = -1;
  for (i = 0; i < N; i++) {
    vv[i] = 0;
    L[i] = 2000000;
  }
  while (Hn > 0) {
    int nd, x;
    delHeap(nd, x);
    vv[nd] = 1;
    if (nd == t) break;
    int nd2, x2;
    for (i = 0; i < N; i++) {
      if (vv[i] == 0 && edge[nd][i] > 0) {
        nd2 = i;
        x2 = x + edge[nd][i];
        if (x2 < L[nd2]) {
          L[nd2] = x2;
          addHeap(nd2, x2);
          last[nd2] = nd;
        }
      }
    }
  }
  int path[1100];
  int pL = 0;
  int v = t;
  while (v != s) {
    int u = last[v];
    G[u][v] = G[v][u] = 1;
    v = u;
  }
}
void solve() {
  int i, j;
  for (i = 0; i < N; i++) {
    for (j = i + 1; j < N; j++) {
      calc(i, j);
    }
  }
  int res = 0;
  for (i = 0; i < M; i++) {
    if (G[Eu[i]][Ev[i]] == 0) res++;
  }
  printf("%d\n", res);
}
int main() {
  freopen("in.txt", "r", stdin);
  scanf("%d%d", &N, &M);
  int i;
  for (i = 0; i < M; i++) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    u--;
    v--;
    Eu[i] = u;
    Ev[i] = v;
    edge[u][v] = edge[v][u] = c;
  }
  solve();
  return 0;
}
