#include <bits/stdc++.h>
using namespace std;
using Weight = long long;
using Vertex = int;
struct Edge {
  Vertex from, to;
  Weight weight;
};
using Graph = std::vector<std::vector<Edge>>;
std::vector<std::vector<Weight>> WarshallFloyd(const Graph& G,
                                               Weight INF = 1e9) {
  std::vector<std::vector<Weight>> d(G.size(),
                                     std::vector<Weight>(G.size(), INF));
  for (int i = 0; i < G.size(); ++i) d[i][i] = 0;
  for (const auto& list : G)
    for (const auto& e : list)
      d[e.from][e.to] = std::min(d[e.from][e.to], e.weight);
  for (int i = 0; i < G.size(); ++i)
    for (int j = 0; j < G.size(); ++j)
      for (int k = 0; k < G.size(); ++k)
        d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
  return d;
}
int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  for (auto i = 0; i < M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    G[a].push_back({a, b, c});
    G[b].push_back({b, a, c});
  }
  auto d = WarshallFloyd(G);
  auto sum = 0;
  int INF = 1e9;
  for (auto E : G)
    for (auto e : E) {
      auto ok = false;
      for (auto u = 0; u < N; ++u)
        for (auto v = 0; v < N; ++v)
          if (d[u][v] == d[u][e.from] + e.weight + d[e.to][v]) ok = true;
      if (!ok) ++sum;
    }
  cout << sum / 2 << endl;
}
