#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(long long N, long long M, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c) {
  vector<vector<ll>> dist(100, vector<ll>(100, 1e9));
  for (int i = 0; i < M; i++) {
    dist[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  ll res = M;
  for (int i = 0; i < M; i++) {
    bool inPath = false;
    for (int j = 0; j < N; j++) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
        inPath = true;
      }
    }
    if (inPath) {
      res--;
    }
  }
  cout << res << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    a[i]--;
    b[i]--;
    scanf("%lld", &c[i]);
  }
  solve(N, M, std::move(a), std::move(b), std::move(c));
  return 0;
}
