#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using graph = vector<vector<ll>>;
const ll INF = 1e18;
void wf(const graph& g, vector<vector<ll>>& d) {
  ll v = (ll)g.size();
  for (ll k = 0; k < v; ++k) {
    for (ll i = 0; i < v; ++i) {
      for (ll j = 0; j < v; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
void solve(void) {
  ll v, e;
  cin >> v >> e;
  graph g(v, vector<ll>(v, -1));
  vector<vector<ll>> dist(v, vector<ll>(v, INF));
  for (ll i = 0; i < e; ++i) {
    ll ta, tb, tc;
    cin >> ta >> tb >> tc;
    --ta, --tb;
    g[ta][tb] = tc;
    g[tb][tb] = tc;
    dist[ta][tb] = tc;
    dist[tb][ta] = tc;
  }
  for (ll i = 0; i < v; ++i) {
    for (ll j = 0; j < v; ++j) {
      if (i == j) dist[i][j] = 0;
    }
  }
  wf(g, dist);
  ll res = 0;
  for (ll i = 0; i < v; ++i) {
    for (ll j = i + 1; j < v; ++j) {
      if (g[i][j] > 0 && (g[i][j] > dist[i][j])) ++res;
    }
  }
  cout << res << endl;
}
int main(void) {
  solve();
  return 0;
}
