#include <bits/stdc++.h>
using ll = long long;
using P = std::pair<ll, ll>;
const ll MOD = 1e9 + 7;
ll dist[101][101] = {MOD};
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  ll n, m, ans = 0;
  std::cin >> n >> m;
  struct Edge {
    ll from, to, cost;
  };
  std::vector<Edge> edges;
  for (ll(i) = (0); i < (n); i++) dist[i][i] = 0;
  for (ll(i) = (0); i < (m); i++) {
    ll a, b, c;
    std::cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    edges.push_back(Edge{a, b, c});
  }
  for (ll(k) = (0); k < (n); k++)
    for (ll(i) = (0); i < (n); i++)
      for (ll(j) = (0); j < (n); j++)
        dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
  for (ll(i) = (0); i < (m); i++) {
    ll a = edges[i].from, b = edges[i].to, c = edges[i].cost;
    bool flag = false;
    for (ll(j) = (0); j < (n); j++) {
      for (ll(k) = (j + 1); k < (n); k++) {
        if (dist[j][k] == dist[j][a] + dist[b][k] + c) {
          flag = true;
        }
        if (flag) break;
      }
      if (flag) break;
    }
    if (flag) ans++;
  }
  std::cout << m - ans;
  return 0;
}
