#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> v(n, vector<ll>(n, INF));
  vector<vector<ll>> check(n, vector<ll>(n, 0));
  for (int i = 0; i < (ll)(n); i++) v.at(i).at(i) = 0;
  for (int i = 0; i < (ll)(n); i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v.at(a).at(b) = c;
    v.at(b).at(a) = c;
    check.at(a).at(b) = 1;
  }
  vector<vector<ll>> u = v;
  for (int k = 0; k < (ll)(n); k++) {
    for (int i = 0; i < (ll)(n); i++) {
      for (int j = 0; j < (ll)(n); j++) {
        v.at(i).at(j) = min(v.at(i).at(j), v.at(i).at(k) + v.at(k).at(j));
      }
    }
  }
  for (int k = 0; k < (ll)(n); k++) {
    for (int i = 0; i < (ll)(n); i++) {
      for (int j = 0; j < (ll)(n); j++) {
        if (v.at(i).at(j) == u.at(i).at(k) + u.at(k).at(j)) {
          check.at(i).at(k) = 0;
          check.at(k).at(i) = 0;
          check.at(k).at(j) = 0;
          check.at(j).at(k) = 0;
        }
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < (ll)(n); i++) {
    for (int j = 0; j < (ll)(n); j++) {
      res += check.at(i).at(j);
    }
  }
  cout << res << endl;
}
