#include <bits/stdc++.h>
using namespace std;
bool visited[100];
int graph[100][100];
bool passed[100][100];
int N, M;
int dis_dfs(int s, int e) {
  int num_min = INT_MAX;
  int min_v = -1;
  if (visited[e]) return num_min;
  visited[s] = true;
  for (int i = 0; i < N; i++) {
    int cost = INT_MAX;
    if (graph[s][i] != 0) {
      if (i == e) {
        cost = graph[s][e];
      } else {
        cost = dis_dfs(i, e);
      }
    }
    if (cost <= num_min) {
      num_min = cost;
      min_v = i;
    }
  }
  if (min_v != -1) {
    passed[s][min_v] = true;
  }
  visited[s] = false;
  return num_min;
}
void all_dfs() {
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      dis_dfs(i, j);
    }
  }
}
int main() {
  int num_passed = 0;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      graph[i][j] = 0;
      passed[i][j] = false;
    }
  }
  for (int i = 0; i < N; i++) {
    visited[i] = false;
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  all_dfs();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (passed[i][j]) num_passed++;
    }
  }
  cout << M - num_passed << endl;
  return 0;
}
