#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
struct Edge {
  int cost, to;
  Edge(int to_, int cost_) : to(to_), cost(cost_) {}
};
using Graph = vector<vector<Edge> >;
void dijkstra(Graph &g, int s, std::vector<int> &dist, std::vector<int> &prev) {
  int n = g.size();
  dist.assign(n, 1e9);
  prev.assign(n, -1);
  std::vector<bool> seen(n, false);
  priority_queue<std::pair<int, int>, vector<std::pair<int, int> >,
                 greater<std::pair<int, int> > >
      que;
  dist[s] = 0;
  que.push(std::pair<int, int>(0, s));
  while (!que.empty()) {
    std::pair<int, int> p = que.top();
    que.pop();
    int node = p.second;
    if (dist[node] < p.second) continue;
    for (int i = 0; i < g[node].size(); i++) {
      Edge e = g[node][i];
      if (dist[e.to] > dist[node] + e.cost) {
        dist[e.to] = dist[node] + e.cost;
        que.push(std::pair<int, int>(dist[e.to], e.to));
        prev[e.to] = node;
      }
    }
  }
}
int main(void) {
  int n, m;
  cin >> n >> m;
  Graph node(n);
  map<std::pair<int, int>, bool> used_path;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    node[a - 1].push_back(Edge(b - 1, c));
    node[b - 1].push_back(Edge(a - 1, c));
    used_path[std::pair<int, int>(a - 1, b - 1)] = false;
  }
  for (int start = 0; start < n; start++) {
    std::vector<int> prev;
    std::vector<int> dist;
    dijkstra(node, start, dist, prev);
    for (int i = 0; i < n; i++) {
      std::vector<int> path;
      if (i == start) {
        continue;
      }
      for (int cur = i; cur != -1; cur = prev[cur]) {
        path.push_back(cur);
      }
      for (int j = 0; j < path.size() - 1; j++) {
        used_path[std::pair<int, int>(path[j], path[j + 1])] = true;
        used_path[std::pair<int, int>(path[j + 1], path[j])] = true;
      }
    }
  }
  int ans = 0;
  for (auto path : used_path) {
    if (!path.second) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
