#include <bits/stdc++.h>
using namespace std;
const long long maxn = 105, maxm = 10005;
vector<pair<long long, long long>> g[maxn], gr[maxn];
vector<long long> U(maxm), V(maxm), W(maxm), candidate(maxm);
long long n, m;
void CandidateEdgesForShortestPathFromSingleSource(long long s) {
  vector<long long> dis(n + 1, 1e15);
  vector<long long> inq(n + 1);
  queue<long long> q;
  dis[s] = 0;
  inq[s] = 1;
  q.push(s);
  while (q.size()) {
    long long u = q.front();
    q.pop();
    inq[u] = 1;
    for (auto [v, i] : g[u]) {
      if (dis[v] > dis[u] + W[i]) {
        dis[v] = dis[u] + W[i];
        if (!inq[v]) {
          inq[v] = 1;
          q.push(v);
        }
      }
    }
  }
  for (long long i = 1; i <= m; i++) {
    if (dis[U[i]] + W[i] == dis[V[i]] || dis[V[i]] + W[i] == dis[U[i]]) {
      candidate[i] = 1;
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> U[i] >> V[i] >> W[i];
    g[U[i]].push_back({V[i], i});
    g[V[i]].push_back({U[i], i});
  }
  for (long long i = 1; i <= n; i++) {
    CandidateEdgesForShortestPathFromSingleSource(i);
  }
  long long ans = m;
  for (long long i = 1; i <= m; i++) {
    ans -= candidate[i];
  }
  cout << ans << '\n';
}
