#include <bits/stdc++.h>
void dijkstra(std::vector<std::vector<int> > &edge, int N, int start,
              std::vector<bool> &used) {
  int M = edge.size();
  std::vector<bool> visited(N, false);
  std::vector<int> min_distance(N, 0);
  visited[start] = true;
  for (int i = 0; i < N - 1; i++) {
    int d = 1e+9, tmp = 0;
    for (int j = 0; j < M; j++) {
      int s = edge[j][0];
      int t = edge[j][1];
      int weight = edge[j][2];
      if (visited[s] == true && visited[t] == false) {
        if (min_distance[s] + weight < d) {
          d = min_distance[s] + weight;
          tmp = j;
        }
      }
      if (visited[s] == false && visited[t] == true) {
        if (min_distance[t] + weight < d) {
          d = min_distance[t] + weight;
          tmp = j;
        }
      }
    }
    used[tmp] = true;
    int u = edge[tmp][0], v = edge[tmp][1];
    if (visited[u] == false) {
      visited[u] = true;
      min_distance[u] = d;
    }
    if (visited[v] == false) {
      visited[v] = true;
      min_distance[v] = d;
    }
  }
}
int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int> > edge(M, std::vector<int>(3, 0));
  for (int i = 0; i < M; i++) {
    scanf(" %d %d %d", &edge[i][0], &edge[i][1], &edge[i][2]);
    edge[i][0]--;
    edge[i][1]--;
  }
  std::vector<bool> used(M, false);
  for (int i = 0; i < N; i++) dijkstra(edge, N, i, used);
  int count = 0;
  for (int i = 0; i < M; i++) {
    if (used[i] == false) count++;
  }
  std::cout << count << std::endl;
}
