#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
ll MOD = 1e18 + 7;
ll doublePower(ll a, ll b) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long d = doublePower(a, b / 2);
    return (d * d) % MOD;
  } else {
    return (a * doublePower(a, b - 1) % MOD);
  }
}
ll MOD_nCr(ll n, ll r, ll MOD) {
  ;
  ll denom = 1;
  ll numer = 1;
  for (ll i = 1; i <= r; i++) numer = (numer * i) % MOD;
  for (ll i = n - r + 1; i <= n; i++) denom = (denom * i) % MOD;
  return (denom * doublePower(numer, MOD - 2) % MOD);
}
signed main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> d(n, vector<ll>(n, 1e18));
  for (ll i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  vector<vector<ll>> d_min;
  for (ll i = 0; i < n; i++) d[i][i] = 0;
  d_min = d;
  for (ll k = 0; k < n; k++)
    for (ll i = 0; i < n; i++)
      for (ll j = 0; j < n; j++)
        d_min[i][j] = min(d_min[i][j], d_min[i][k] + d_min[k][j]);
  vector<vector<bool>> used(n, vector<bool>(n, true));
  for (ll k = 0; k < n; k++)
    for (ll i = 0; i < n; i++)
      for (ll j = 0; j < n; j++)
        if (d_min[i][j] == d_min[i][k] + d_min[k][j]) {
          if (i == j || i == k || k == j) continue;
          used[i][k] = used[k][j] = used[k][i] = used[j][k] = false;
        }
  ll ans = 0;
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < n; j++)
      if (used[i][j] && i != j && d[i][j] != d_min[i][j] && d[i][j] != 1e18)
        ans++;
  cout << ans / 2 << endl;
  return 0;
}
