#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;
template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  for (ll j = 0; j < (ll)(v.size()); ++j) i >> v[j];
  return i;
}
template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) { return to_string(x).size(); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
void warshall_floyd(ll N, vvll& d) {
  for (ll k = 0; k < (ll)(N); ++k)
    for (ll i = 0; i < (ll)(N); ++i)
      for (ll j = 0; j < (ll)(N); ++j) chmin(d[i][j], d[i][k] + d[k][j]);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  vvll d(N, vll(N, INF));
  for (ll i = 0; i < (ll)(N); ++i) d[i][i] = 0;
  vll A(M), B(M), C(M);
  for (ll i = 0; i < (ll)(M); ++i) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
    d[A[i]][B[i]] = C[i];
    d[B[i]][A[i]] = C[i];
  }
  warshall_floyd(N, d);
  ll ans = 0;
  for (ll m = 0; m < (ll)(M); ++m) {
    bool ok = false;
    for (ll i = 0; i < (ll)(N); ++i) {
      for (ll j = 0; j < (ll)(N); ++j) {
        if (d[i][j] == d[i][A[i]] + C[m] + d[B[i]][j]) ok = true;
      }
    }
    if (!ok) ans++;
  }
  cout << ans << "\n";
  return 0;
}
