#include using namespace std; using ll = long long; using Ul = unsigned long long; using cl = const ll; using VI = vector; using VS = vector; using VC = vector; using VL = vector; using VU = vector
    ; using VB = vector; using PI = pair; using PL = pair; void fix(int a){cout << fixed << setprecision(a);} template bool chmax(t&a,u b) {if(a bool chmin(t&a,u b) {if(b>N>>M; VI C(N),dist(N,-1),count(N,-1); vector G(N); rep(i,N) cin>>C[i]; rep(i,M) { int a,b; cin>>a>>b; a--; b--; if(C[a]==C[b]) { G[a].push_back(b); G[b].push_back(a); } else continue; } queue que; rep(i,N) { if(dist[i]==-1) { que.push(i); dist[i]=0; count[C[i]]++; } while(!que.empty()) { int t=que.front(); que.pop(); rep(j,G[t].size()) { if(dist[G[t][j]]==-1) { que.push(G[t][j]); dist[G[t][j]]=0; } } } } int Ans=0; rep(i,N) { if(count[i]>=0) Ans+=count[i]; } cout<