#include <bits/stdc++.h>
using namespace ::std;
bool myless(vector<int> A, vector<int> B) {
  if (A[2] != B[2]) {
    return A[2] < B[2];
  } else if (A[0] != B[0]) {
    return A[0] < B[0];
  }
  return A[1] < B[1];
}
void solve() {
  int N, M;
  cin >> N >> M;
  int a, b, c;
  vector<vector<int>> data;
  data.reserve(M);
  vector<int> temp = vector<int>(3, 0);
  for (int cou = 0; cou < M; cou++) {
    cin >> a >> b >> c;
    if (a < b) {
      temp[0] = a - 1;
      temp[1] = b - 1;
    } else {
      temp[0] = b - 1;
      temp[1] = a - 1;
    }
    temp[2] = c;
    data.push_back(temp);
  }
  sort(data.begin(), data.end(), myless);
  vector<vector<int>>::iterator itr, end;
  itr = data.begin();
  end = data.end();
  vector<vector<int>> pathM = vector<vector<int>>(N, vector<int>(N, 0));
  int count = 0;
  for (; itr != end; itr++) {
    a = (*itr)[0];
    b = (*itr)[1];
    c = (*itr)[2];
    if (pathM[a][b] == 0 || c < pathM[a][b]) {
      pathM[a][b] = c;
      pathM[b][a] = c;
      for (int cen = 0; cen < N; cen++) {
        if (a == cen || b == cen) continue;
        if (pathM[a][cen] != 0) {
          if (pathM[b][cen] == 0) {
            pathM[b][cen] = pathM[b][a] + pathM[a][cen];
            pathM[cen][b] = pathM[b][a] + pathM[a][cen];
          } else if (pathM[b][a] + pathM[a][cen] < pathM[b][cen]) {
            pathM[b][cen] = pathM[b][a] + pathM[a][cen];
            pathM[cen][b] = pathM[b][a] + pathM[a][cen];
          }
        }
        if (pathM[b][cen] != 0) {
          if (pathM[a][cen] == 0) {
            pathM[a][cen] = pathM[a][b] + pathM[b][cen];
            pathM[cen][a] = pathM[a][b] + pathM[b][cen];
          } else if (pathM[a][b] + pathM[b][cen] < pathM[a][cen]) {
            pathM[a][cen] = pathM[a][b] + pathM[b][cen];
            pathM[cen][a] = pathM[a][b] + pathM[b][cen];
          }
        }
      }
    } else {
      count++;
    }
  }
  cout << count << endl;
}
int main(void) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed;
  solve();
  return 0;
}
