#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> dist(n, vector<ll>(n));
  for (ll i = 0; i < n; ++i)
    for (ll j = 0; j < n; ++j) dist[i][j] = INF;
  for (ll i = 0; i < m; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  ll ans = 0;
  for (ll k = 0; k < n; ++k)
    for (ll i = 0; i < n; ++i)
      for (ll j = 0; j < n; ++j) {
        if (dist[i][k] >= INF || dist[k][j] >= INF) continue;
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
          if (dist[i][j] < INF) ans++;
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
  cout << ans / 2 << endl;
}
