#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
constexpr ll MAX_N = 100;
ll cost[MAX_N][MAX_N];
ll edge[MAX_N][MAX_N];
ll N, M;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      if (i == j) {
        cost[i][j] = 0;
      } else {
        cost[i][j] = cost[j][i] = 1e18;
      }
    }
  }
  vector<ll> A, B, C;
  for (ll i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    A.push_back(a);
    B.push_back(b);
    C.push_back(c);
    cost[a][b] = cost[b][a] = c;
  }
  for (ll k = 0; k < N; k++) {
    for (ll i = 0; i < N; i++) {
      for (ll j = i + 1; j < N; j++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  ll ans = M;
  for (ll i = 0; i < M; i++) {
    bool shortest = false;
    for (ll j = 0; j < N; j++) {
      if (cost[j][A[i]] + C[i] == cost[j][B[i]]) {
        shortest = true;
      }
    }
    if (shortest) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
