#include <bits/stdc++.h>
using namespace std;
int N, M;
int D[100][100];
int E[100][100];
int pv[100][100];
int pe[100][100];
vector<pair<int, pair<int, int> > > G[100];
bool U[100];
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      D[i][j] = 114514191;
      E[i][j] = 114514191;
      pv[i][j] = i;
      pe[i][j] = 114514191;
    }
    D[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    D[a][b] = c, E[a][b] = i;
    D[b][a] = c, E[b][a] = i;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (D[i][k] + D[k][j] < D[i][j]) {
          D[i][j] = D[i][k] + D[k][j];
          pv[i][j] = pv[k][j];
        }
      }
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      int c = pv[k][i], lc = i;
      while (k != lc) {
        if (E[c][lc] != 114514191) {
          U[E[c][lc]] = true;
        }
        lc = c, c = pv[k][c];
      }
    }
  }
  int c = 0;
  for (int i = 0; i < M; i++) {
    if (!U[i]) c++;
  }
  cout << c << "\n";
  return 0;
}
