#include <bits/stdc++.h>
long long int N, M, ans;
std::vector<std::vector<long long int>> dist;
void warshall_floyd(long long int V) {
  for (long long int k = 1; k <= V; ++k) {
    for (long long int i = 1; i <= V; ++i) {
      for (long long int j = 1; j <= V; ++j) {
        dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}
int main() {
  std::cin >> N >> M;
  std::vector<long long int> a(M), b(M), c(M);
  dist.resize(N + 1);
  for (int i = 0; i < dist.size(); ++i) dist[i].resize(N + 1);
  for (int i = 0; i < M; ++i) {
    std::cin >> a[i] >> b[i] >> c[i];
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }
  warshall_floyd(N);
  for (int i = 0; i < M; ++i) {
    bool flag = false;
    for (int j = 0; j < N; ++j) {
      if (dist[j + 1][a[i]] + c[i] == dist[j + 1][b[i]] ||
          dist[j + 1][b[i]] + c[i] == dist[j + 1][a[i]]) {
        flag = true;
        break;
      }
    }
    if (!flag) ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}
