#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n), b(n), c(n);
  vector<vector<ll>> dist(n, vector<ll>(n));
  for (ll i = (0); i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }
  for (ll i = (0); i < (n); i++) {
    for (ll j = (0); j < (n); j++) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = INF;
    }
  }
  for (ll i = (0); i < (m); i++) {
    chmin(dist[a[i]][b[i]], c[i]);
    chmin(dist[b[i]][a[i]], c[i]);
  }
  for (ll k = (0); k < (n); k++)
    for (ll i = (0); i < (n); i++)
      for (ll j = (0); j < (n); j++) chmin(dist[i][j], dist[i][k] + dist[k][j]);
  ll ans = m;
  for (ll i = (0); i < (m); i++) {
    bool is_shortest = false;
    for (ll j = (0); j < (n); j++)
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) is_shortest = true;
    if (is_shortest) ans--;
  }
  cout << ans << endl;
}
