#include <bits/stdc++.h>
using namespace std;
int main() {
  const int INF = 1000000;
  int N, M;
  cin >> N >> M;
  int dist[100][100];
  vector<pair<int, int> > edges;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = i == j ? 0 : INF;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    dist[a - 1][b - 1] = c;
    dist[b - 1][a - 1] = c;
    edges.push_back(pair<int, int>(a - 1, b - 1));
  }
  int min_dist[100][100];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      min_dist[i][j] = dist[i][j];
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        min_dist[i][j] = min(min_dist[i][j], min_dist[i][k] + min_dist[k][j]);
      }
    }
  }
  int ans = 0;
  int check_dist[100][100];
  for (auto it = edges.begin(); it != edges.end(); ++it) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        check_dist[i][j] = dist[i][j];
      }
    }
    int bu = dist[it->first][it->second];
    check_dist[it->first][it->second] = INF;
    check_dist[it->second][it->first] = INF;
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          check_dist[i][j] =
              min(check_dist[i][j], check_dist[i][k] + check_dist[k][j]);
        }
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (dist[i][j] <= INF && min_dist[i][j] != check_dist[i][j]) {
          goto next;
        }
      }
    }
    ans++;
  next:
    check_dist[it->first][it->second] = bu;
    check_dist[it->second][it->first] = bu;
  }
  cout << ans << endl;
}
