#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
const ll INF = 1LL << 32;
int main() {
  ll n, m;
  cin >> n >> m;
  vvll dist(n, vll(n, INF));
  vvP es(n);
  for (ll i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    es[a].push_back(P(b, c));
  }
  for (ll k = 0; k < (n); ++k)
    for (ll i = 0; i < (n); ++i)
      for (ll j = 0; j < (n); ++j)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  ll ans = 0;
  for (ll j = 0; j < n; j++) {
    for (auto p : es[j]) {
      for (ll i = 0; i < n; i++) {
        ll b = p.first;
        ll c = p.second;
        if (dist[i][j] + c == dist[i][b]) {
          ans++;
          break;
        }
      }
    }
  }
  cout << m - ans << endl;
  return 0;
}
