#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = (1LL << 62);
struct edge {
  long long to;
  long long cost;
};
const long long MAX_N = 510;
long long N, M;
vector<edge> edges[MAX_N];
long long d[MAX_N];
long long pv[MAX_N];
long long used[MAX_N][MAX_N];
void dijkstra(long long start) {
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  fill(d, d + MAX_N, INF);
  fill(pv, pv + MAX_N, -1);
  d[start] = 0;
  que.push(pair<long long, long long>(0, start));
  while (!que.empty()) {
    pair<long long, long long> p = que.top();
    que.pop();
    long long from = p.second;
    long long p_cost = p.first;
    if (d[from] < p_cost) {
      continue;
    }
    for (long long i = 0; i < edges[from].size(); i++) {
      edge e = edges[from][i];
      long long next_cost = d[from] + e.cost;
      if (d[e.to] > next_cost) {
        d[e.to] = next_cost;
        que.push(pair<long long, long long>(d[e.to], e.to));
        pv[e.to] = from;
      }
    }
  }
}
void calc() {
  scanf("%lld %lld", &N, &M);
  for (long long i = 0; i < M; i++) {
    long long from, to, cost;
    scanf("%lld %lld %lld", &from, &to, &cost);
    edges[from].emplace_back(edge{to, cost});
    edges[to].emplace_back(edge{from, cost});
  }
  for (long long start = 1; start <= N; start++) {
    dijkstra(start);
    for (long long goal = start + 1; goal <= N; goal++) {
      if (start == goal) {
        continue;
      }
      long long current = goal;
      for (;;) {
        if (current == start) {
          break;
        }
        long long next = pv[current];
        if (next == -1) {
          break;
        }
        used[current][next] = 1;
        used[next][current] = 1;
        current = next;
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= N; i++) {
    for (long long j = 1; j < edges[i].size(); j++) {
      if (!used[i][j]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
int main() { calc(); }
