#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 1LL << 60;
constexpr long long MOD = 1000000007;
constexpr long long MAX_N = 105;
constexpr long long MAX_M = 1005;
constexpr long long dx[] = {0, 1, 0, -1};
constexpr long long dy[] = {1, 0, -1, 0};
long long d[MAX_N], n, m, flg[MAX_M];
vector<pair<long long, long long>> G[MAX_N];
tuple<long long, long long, long long> ed[MAX_M];
void Dijkstra(long long s) {
  fill(d, d + MAX_N, INF);
  d[s] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  pq.push({0, s});
  while (pq.size()) {
    pair<long long, long long> p = pq.top();
    pq.pop();
    long long v = p.second;
    if (d[v] < p.first) continue;
    for (long long i = 0; i < G[v].size(); ++i) {
      long long to = G[v][i].second, cost = G[v][i].first;
      if (d[to] <= p.first + cost) continue;
      d[to] = p.first + cost;
      pq.push({d[to], to});
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    ed[i] = {a, b, c};
    G[a].push_back({c, b});
    G[b].push_back({c, a});
  }
  for (long long i = 0; i < n; ++i) {
    Dijkstra(i);
    for (long long j = 0; j < m; ++j) {
      long long a = get<0>(ed[j]), b = get<1>(ed[j]), cost = get<2>(ed[j]);
      if (min(d[a], d[b]) + cost == max(d[a], d[b])) {
        flg[j] = true;
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < m; ++i) {
    if (!flg[i]) ans++;
  }
  cout << ans << endl;
}
