#include <bits/stdc++.h>
int D[110][110];
int INF = 1 << 30;
std::vector<std::tuple<int, int, int> > E;
int main() {
  int N, M;
  std::cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (i == j)
        D[i][j] = 0;
      else
        D[i][j] = INF;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    std::cin >> a >> b >> c;
    D[a][b] = c;
    E.push_back(std::tuple<int, int, int>{a, b, c});
  }
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        D[i][j] = std::min(D[i][j], D[i][k] + D[k][j]);
      }
    }
  }
  for (auto u : E) {
    int a, b, c;
    std::tie(a, b, c) = u;
    for (int i = 1; i <= N; i++) {
      if (D[i][a] + c == D[i][b] || D[i][b] + c == D[i][a]) break;
      if (i == N) M--;
    }
  }
  std::cout << M << std::endl;
  return 0;
}
