#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1 << 30;
const ll mod = 1000000007LL;
bool seen[1500];
struct dijkstra {
  struct Node {
    vector<int> edges_to;
    vector<int> edges_cost;
    vector<int> edges_num;
    bool done;
    int cost;
    int from;
  };
  vector<Node> graph;
  void init(int N) { graph.resize(N); }
  void add(int from, int to, int cost, int num) {
    graph[from].edges_to.push_back(to);
    graph[from].edges_cost.push_back(cost);
    graph[from].edges_num.push_back(num);
  }
  void shortest(int start) {
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>,
                   greater<tuple<int, int, int>>>
        d;
    d.push(make_tuple(0, start, -1));
    while (!d.empty()) {
      tuple<int, int, int> p = d.top();
      d.pop();
      Node &point = graph[get<1>(p)];
      if (point.done) continue;
      point.done = true;
      point.cost = get<0>(p);
      point.from = get<2>(p);
      if (point.from != -1) seen[point.from] = true;
      for (int i = 0; i < (int)point.edges_to.size(); i++) {
        if (graph[point.edges_to[i]].done) continue;
        d.push(make_tuple(point.cost + point.edges_cost[i], point.edges_to[i],
                          point.edges_num[i]));
      }
    }
  }
};
int main() {
  int N, M;
  cin >> N >> M;
  dijkstra g;
  g.init(N);
  for (int i = 0; i < M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    g.add(x - 1, y - 1, z, i);
    g.add(y - 1, x - 1, z, i);
  }
  for (int i = 0; i < N; i++) {
    g.shortest(i);
    for (int j = 0; j < N; j++) {
      g.graph[i].done = false;
      g.graph[i].cost = 0;
      g.graph[i].from = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (!seen[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}
