#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = std::tuple<int, int>;
const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1},
          dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
int N, M;
int d[300][300];
int as[200], bs[200], cs[200];
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> N >> M;
  fill(&d[0][0], &d[0][0] + 300 * 300, 1001001001);
  for (int i = 0; i < N; ++i) {
    d[i][i] = 0;
  }
  for (int i = 0; i < M; ++i) {
    std::cin >> as[i] >> bs[i] >> cs[i];
    --as[i];
    --bs[i];
    d[as[i]][bs[i]] = min(d[as[i]][bs[i]], cs[i]);
    d[bs[i]][as[i]] = min(d[bs[i]][as[i]], cs[i]);
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i < M; ++i) {
    bool canUse = false;
    for (int j = 0; j < N; ++j) {
      if (d[j][as[i]] == d[j][bs[i]] + cs[i] ||
          d[j][bs[i]] == d[j][as[i]] + cs[i]) {
        canUse = true;
      }
    }
    if (!canUse) {
      ++res;
    }
  }
  std::cout << res << std::endl;
}
