#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
ll INF = 1000000000000;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<pll>> g(n, vector<pll>(0));
  vvll d(n, vll(n, INF));
  for (int i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g.at(a).emplace_back(b, c);
    g.at(b).emplace_back(a, c);
    d.at(a).at(b) = c;
    d.at(b).at(a) = c;
  }
  for (int i = 0; i < n; i++) d.at(i).at(i) = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < g.at(i).size(); j++) {
      ll pi = i;
      ll pj = g.at(i).at(j).first;
      ll cost = g.at(i).at(j).second;
      bool ok = false;
      for (int k = 0; k < n; k++) {
        if (d.at(k).at(pi) + cost == d.at(k).at(pj)) ok = true;
        if (d.at(k).at(pj) + cost == d.at(k).at(pi)) ok = true;
      }
      cnt += ok;
    }
  }
  cnt /= 2;
  cout << m - cnt << endl;
}
