#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long long int INF = 2 << 28;
int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M], c[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int d[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      d[i][j] = INF;
    }
  }
  for (int i = 0; i < M; i++) {
    d[a[i] - 1][b[i] - 1] = c[i];
    d[b[i] - 1][a[i] - 1] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int count = 0;
  for (int i = 0; i < M; i++) {
    int dd[N][N];
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dd[j][k] = INF;
      }
    }
    for (int j = 0; j < M; j++) {
      if (i == j) continue;
      dd[a[j] - 1][b[j] - 1] = c[j];
      dd[b[j] - 1][a[j] - 1] = c[j];
    }
    for (int k = 0; k < N; k++) {
      for (int ii = 0; ii < N; ii++) {
        for (int j = 0; j < N; j++) {
          dd[ii][j] = min(dd[ii][j], dd[ii][k] + dd[k][j]);
        }
      }
    }
    bool end = false;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (dd[i][j] != d[i][j]) {
          i = N;
          end = true;
          break;
        }
      }
    }
    if (!end) count++;
  }
  cout << count << endl;
}
