func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   int n, m, f[N], vis[N], cnt;   int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }   struct node {     int x, y, w;   } a[N];   bool cmp(node a, node b) { return a.w < b.w; }   int main() {     while (cin >> n >> m) {       int ans = 0;       for (int i = 1; i <= n; i++) f[i] = i;       for (int i = 1; i <= m; i++) {         int x, y, k;         cin >> x >> y >> k;         a[i].x = x;         a[i].y = y;         a[i].w = k;       }       sort(a + 1, a + 1 + m, cmp);       int mx = 0;       for (int i = 1; i <= m;) {         int j = i;         while (a[i].w == a[j].w) j++;         cnt = 0;         for (int k = i; k < j; k++)           if (find(a[k].x) != find(a[k].y)) cnt++;         for (int k = i; k < j; k++) {           if (find(a[k].x) != find(a[k].y)) {             f[find(a[k].x)] = find(a[k].y);             cnt--;           }         }         ans += cnt;         i = j;       }       cout << ans << endl;     }   }   