#include <bits/stdc++.h>
struct edge {
  long long int to, cost;
};
const long long int inf = 112345678;
long long int N, M, ans;
std::vector<long long int> a, b, c, dist;
std::vector<edge> G[112];
std::vector<std::vector<long long int>> d;
void warshall_floyd(long long int V) {
  for (long long int k = 1; k <= V; ++k) {
    for (long long int i = 1; i <= V; ++i) {
      for (long long int j = 1; j <= V; ++j) {
        d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
void dijkstra(long long int s) {
  std::priority_queue<std::pair<long long int, long long int>,
                      std::vector<std::pair<long long int, long long int>>,
                      std::greater<std::pair<long long int, long long int>>>
      que;
  std::fill(dist.begin(), dist.end(), inf);
  dist[s] = 0;
  que.push(std::pair<long long int, long long int>(0, s));
  while (!que.empty()) {
    std::pair<long long int, long long int> p = que.top();
    que.pop();
    long long int v = p.second;
    if (dist[v] < p.first) {
      continue;
    }
    for (int i = 0; i < G[v].size(); ++i) {
      edge e = G[v][i];
      if (dist[e.to] > dist[v] + e.cost) {
        dist[e.to] = dist[v] + e.cost;
        que.push(std::pair<long long int, long long int>(dist[e.to], e.to));
      }
    }
  }
}
int main() {
  std::cin >> N >> M;
  a.resize(M), b.resize(M), c.resize(M);
  for (int i = 0; i < M; ++i) std::cin >> a[i] >> b[i] >> c[i];
  d.resize(N + 1);
  dist.resize(N + 1);
  for (int i = 0; i < d.size(); ++i) d[i].resize(N + 1);
  for (int i = 0; i < d.size(); ++i)
    for (int j = 0; j < d[i].size(); ++j) d[i][j] = inf;
  for (int i = 0; i < N; ++i) d[i + 1][i + 1] = 0;
  for (int i = 0; i < M; ++i) d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  warshall_floyd(N);
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) G[j + 1].clear();
    for (int j = 0; j < M; ++j) {
      if (i == j) continue;
      G[a[j]].push_back({b[j], c[j]});
      G[b[j]].push_back({a[j], c[j]});
    }
    bool flag = false;
    for (int j = 0; j < N; ++j) {
      dijkstra(j + 1);
      for (int k = 0; k < N; ++k) {
        if (dist[k + 1] != d[j + 1][k + 1]) {
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
    if (!flag) ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}
