#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T gcd(const T &a, const T &b) {
  return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(const T &a, const T &b) {
  return a / gcd(a, b) * b;
}
using ll = long signed long;
using ull = long unsigned long;
using cll = long long const;
using ld = long double;
using namespace std;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> g(n, vector<ll>(n, 0x7FFFFFFF));
  for (long long i = 0, i_len = (n); i < i_len; i++) g[i][i] = 0;
  vector<ll> a(m), b(m), c(m);
  for (long long i = 0, i_len = (m); i < i_len; i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
  }
  for (long long k = 0, k_len = (n); k < k_len; k++)
    for (long long i = 0, i_len = (n); i < i_len; i++)
      for (long long j = 0, j_len = (n); j < j_len; j++) {
        chmin(g[i][j], g[i][k] + g[k][j]);
      }
  ll ans = 0;
  for (long long k = 0, k_len = (m); k < k_len; k++) {
    bool used = false;
    for (long long j = 0, j_len = (n); j < j_len; j++) {
      for (long long i = 0, i_len = (j); i < i_len; i++) {
        if (g[i][a[k]] + c[k] + g[b[k]][j] == g[i][j]) {
          used = true;
          break;
        }
      }
      if (used) break;
    }
    if (!used) ans++;
  }
  std::cout << ans << endl;
}
