ll@n,@m,@c[n]--,d[n]{},z=0;z+=!!d[c[0..n-1]]++;unionFind f('m',n,1);rep(m){ll@u--,@v--;z-=c[u]-c[v]?0:f(u,v);}wt(z);