#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
using vpl = vector<pl>;
using vvpl = vector<vpl>;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1};
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll n, m;
  cin >> n >> m;
  vvl v(n, vl(n, inf));
  vpl p(n);
  vl w(n);
  for (ll i = 0; i < n; i++) v[i][i] = 0;
  for (ll i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v[a][b] = c;
    v[b][a] = c;
    p[i].first = a;
    p[i].second = b;
    w[i] = c;
  }
  for (ll k = 0; k < n; k++)
    for (ll i = 0; i < n; i++)
      for (ll j = 0; j < n; j++) chmin(v[i][j], v[i][k] + v[k][j]);
  ll ans = 0;
  for (ll i = 0; i < m; i++) {
    ll x = p[i].first, y = p[i].second, c = w[i];
    if (v[x][y] != c) ans++;
  }
  cout << ans << endl;
}
