#include <bits/stdc++.h>
using namespace std;
map<set<int>, int> weight;
bool chmin(int& a, int b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
int dfs(int parent_node, int goal_node, map<int, bool>& passed,
        map<int, vector<int>> connectTo, int base) {
  int best = base;
  passed[parent_node] = true;
  for (auto i : connectTo[parent_node]) {
    if (passed[i]) continue;
    if (i == goal_node) {
      chmin(best, weight[{parent_node, i}]);
    } else if (weight[{parent_node, i}] < base) {
      chmin(best,
            weight[{parent_node, i}] + dfs(i, goal_node, passed, connectTo,
                                           base - weight[{parent_node, i}]));
    }
  }
  passed[parent_node] = false;
  return best;
}
int main() {
  int N, M;
  cin >> N >> M;
  map<int, vector<int>> connectTo;
  int a[M], b[M], c;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c;
    connectTo[a[i]].push_back(b[i]);
    connectTo[b[i]].push_back(a[i]);
    weight[{a[i], b[i]}] = c;
  }
  int ans = 0;
  map<int, bool> passed;
  for (int i = 0; i < M; i++) {
    int best = dfs(a[i], b[i], passed, connectTo, weight[{a[i], b[i]}]);
    if (best != weight[{a[i], b[i]}]) ans++;
  }
  cout << ans << endl;
  return 0;
}
