#include using namespace std; #define int long long #define endl '\n' const int N=2e5+10; int n,m; int f[N]; struct P{ int a,b,c; bool operator<(const P&x){ return cS[b]) swap(a,b); S[b]+=S[a]; f[a]=b; } }dsu; signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("in.txt","r",stdin); cin>>n>>m; dsu.init(n); for(int i=0;i>a>>b>>c; g[i]={a,b,c}; } sort(g,g+m); int ans=0; for(int i=0;i