#include using namespace std; int main(){ int n,m,a,b,t; cin >> n >> m; vector C(n),CI(n),D(n,1); for (int& a:C) (cin >> a),++CI[a-1]; while(m--){ cin >> a >> b; if (C[a-1]==C[b-1]) CI[C[a-1]-1]-=D[b-1],t=D[a-1],D[a-1]+=D[b-1],D[b-1]+=t; } int r(0); for (int a:CI) if (a) r+=a-1; cout << r << endl; }