#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e15;
const ll MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> info[N];
  ll edge[M][3];
  for (ll i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[i][0] = a - 1;
    edge[i][1] = b - 1;
    edge[i][2] = c;
    info[a - 1].push_back(make_pair(b - 1, c));
    info[b - 1].push_back(make_pair(a - 1, c));
  }
  ll dist[N][N];
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
  for (ll i = 0; i < N; i++) {
    ll nowdist[N];
    for (ll j = 0; j < N; j++) {
      if (j == i)
        nowdist[j] = 0;
      else
        nowdist[j] = INF;
    }
    que.emplace(0, 0);
    while (que.size()) {
      ll d = que.top().first, v = que.top().second;
      que.pop();
      for (auto j : info[v]) {
        ll nv = j.first, nc = j.second;
        if (nowdist[nv] > d + nc) {
          nowdist[nv] = d + nc;
          que.emplace(nowdist[nv], nv);
        }
      }
    }
    for (ll j = 0; j < N; j++) dist[i][j] = nowdist[j];
  }
  ll count = 0;
  for (ll i = 0; i < M; i++) {
    ll a = edge[i][0], b = edge[i][1], c = edge[i][2];
    for (ll j = 0; j < N; j++) {
      if (j != a and dist[j][b] == dist[j][a] + c)
        count++;
      else if (j != b and dist[j][a] == dist[j][b] + c)
        count++;
    }
  }
  cout << M - count << endl;
  return 0;
}
