#include <bits/stdc++.h>
const long long int inf = 1123456789;
std::vector<std::vector<long long int>> dist;
std::set<std::pair<long long int, long long int>> res;
void warshall_floyd(long long int V) {
  for (long long int k = 0; k < V; ++k) {
    for (long long int i = 0; i < V; ++i) {
      for (long long int j = 0; j < V; ++j) {
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          if (dist[i][j] != inf)
            res.insert(std::make_pair(std::min(i, j), std::max(i, j)));
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
}
int main() {
  long long int N, M;
  std::cin >> N >> M;
  std::vector<long long int> a(M), b(M), c(M);
  for (int i = 0; i < M; ++i) std::cin >> a[i] >> b[i] >> c[i];
  dist.resize(N);
  for (int i = 0; i < dist.size(); ++i) dist[i].resize(N, inf);
  for (int i = 0; i < N; ++i) dist[i][i] = 0;
  for (int i = 0; i < M; ++i)
    dist[a[i] - 1][b[i] - 1] = dist[b[i] - 1][a[i] - 1] = c[i];
  warshall_floyd(N);
  long long int ans = 0;
  for (auto e : res) {
    for (int i = 0; i < M; ++i) {
      if (e.first == a[i] - 1 && e.second == b[i] - 1) {
        ++ans;
        break;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
