#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using ld = long double;
const ll C_MAX = 1000;
ll n, m, ans;
vll a, b, c;
vvll d;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  cout.setf(ios::fixed);
  cout.precision(32);
  ;
  cin >> n >> m;
  d.assign(n, vll(n, C_MAX + 1));
  a.resize(m);
  b.resize(m);
  c.resize(m);
  for (ll i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
    d[b[i]][a[i]] = min(d[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++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  ans = m;
  for (ll i = 0; i < m; i++) {
    for (ll j = 0; j < n; j++) {
      if (abs(d[j][a[i]] - d[j][b[i]]) == c[i]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
}
