#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  ll d[110][110];
  for (ll i = 0; i < (N); i++) {
    for (ll j = 0; j < (N); j++) {
      d[i][j] = INT_MAX;
    }
  }
  vector<ll> a(M), b(M);
  vector<vector<bool>> exist(N, vector<bool>(N, false));
  for (ll i = 0; i < (M); i++) {
    ll a[i], b[i], c;
    cin >> a[i] >> b[i] >> c;
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c;
    d[b[i]][a[i]] = c;
    exist[b[i]][a[i]] = true;
    exist[a[i]][b[i]] = true;
  }
  vector<vector<bool>> memo(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[i][j] > d[i][k] + d[k][j]) {
          memo[i][k] = false;
          memo[k][j] = false;
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < (N); i++) {
    for (ll j = 0; j < (N); j++) {
      if (exist[i][j] && (i != j) && memo[i][j]) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
