#include <bits/stdc++.h>   using namespace std;   const int maxn = 202000;   int n, m;   struct edge {     int u, v, w;   } edges[maxn];   int pre[maxn];   vector<edge> vec;   int found(int x) {     int rx = x;     while (pre[rx] != rx) rx = pre[rx];     while (pre[x] != rx) {       int tmp = pre[x];       pre[x] = rx;       x = tmp;     }     return rx;   }   int cmp(edge alpha, edge beta) { return alpha.w < beta.w; }   void read() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++)       scanf( %d%d%d , &edges[i].u, &edges[i].v, &edges[i].w);     sort(edges + 1, edges + m + 1, cmp);   }   void work() {     int ans = 0;     for (int i = 1; i <= n; i++) pre[i] = i;     for (int i = 1; i <= m;) {       int j = i;       vec.clear();       while (edges[i].w == edges[j].w) {         if (found(edges[j].u) == found(edges[j].v)) {           j++;           continue;         }         vec.push_back(edges[j]);         j++;       }       for (int k = 0; k < vec.size(); k++) {         if (found(vec[k].u) == found(vec[k].v))           ans++;         else           pre[found(vec[k].u)] = found(vec[k].v);       }       i = j;     }     printf( %d n , ans);   }   int main() {     read();     work();     return 0;   }   