#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int n, fa[200050], am[200050];
int m, k;
int color[200050];
void init()
{
	for (int i = 1; i<=n; i++)
	{
		color[i] = 0;
		fa[i] = i;
		am[i] = 1;
	}
}
int findFarther(int x)
{
	while (fa[x] != x) {
		x = fa[x];
	}
	return x;
}

void Union(int x, int y)
{
	int rootx = findFarther(x), rooty = findFarther(y);
	if (rootx != rooty) {
		if (am[rootx]>am[rooty]) {
			fa[rooty] = rootx;
			am[rootx] += am[rooty];
		}
		else {
			fa[rootx] = rooty;
			am[rooty] += am[rootx];
		}
	}
}

void show(int x)
{
	for (int i = 1; i <= x; i++)
	{
		cout << findFarther(i) << ' ';
	}
	cout << endl;
}

int main()
{

	while (cin >> n >> m >> k)
	{
		int flag[200050] = { 0 };
		init();
		for (int i = 1; i <= n; i++)
		{
			cin >> color[i];
		}
		for (int i = 0; i < m; i++)
		{
			int a, b;
			cin >> a >> b;
			Union(a, b);
			flag[a] = 1;
			flag[b] = 1;
		}
		//show(n);

		int res = 0;
		for (int i = 1; i <= n; i++)
		{
			int temp[20050];
			int temp_point = 0;
			if (flag[i])
			{
				for (int j = i; j <= n; j++)
				{
					if (findFarther(i) == findFarther(j))
					{
						temp[temp_point] = j;
						temp_point++;
						flag[j] = 0;
					}
				}
			}
			for (int j = 0; j < temp_point; j++)
			{
				temp[j] = color[temp[j]];
			}
			sort(temp, temp + temp_point);
			int max = 0;
			int temp_max = 1;

			for (int j = 1; j < temp_point; j++)
			{
				if (temp[j] != temp[j - 1]) temp_max = 0;
				temp_max++;
				if (temp_max > max)
					max = temp_max;
			}
			res += temp_point - max;
		}
		cout << res << endl;
	}
    return 0;
}


#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int n, fa[200050], am[200050];
int m, k;
int color[200050];
void init()
{
	for (int i = 1; i<=n; i++)
	{
		color[i] = 0;
		fa[i] = i;
		am[i] = 1;
	}
}
/*int findFarther(int x)
{
	while (fa[x] != x) {
		x = fa[x];
	}
	return x;
}*/

int findFarther(int v)      //找元素所在集合的代表元(因为用了路径压缩，路径压缩的主要目的是为了尽快的确定元素所在的集合）
{
	int t1, t2 = v;
	while (v != fa[v])
		v = fa[v];
	while (t2 != fa[t2])        //这里优化的思路还是路径压缩（进一步的在查找函数执行的过程中压缩路径），很神奇!
	{
		t1 = fa[t2];
		fa[t2] = v;
		t2 = t1;
	}
	return v;
}
void Union(int x, int y)
{
	int rootx = findFarther(x), rooty = findFarther(y);
	if (rootx != rooty) {
		if (am[rootx]>am[rooty]) {
			fa[rooty] = rootx;
			am[rootx] += am[rooty];
		}
		else {
			fa[rootx] = rooty;
			am[rooty] += am[rootx];
		}
	}
}

void show(int x)
{
	for (int i = 1; i <= x; i++)
	{
		cout << findFarther(i) << ' ';
	}
	cout << endl;
}

int main()
{

	while (cin >> n >> m >> k)
	{
		int flag[200050] = { 0 };
		init();
		for (int i = 1; i <= n; i++)
		{
			cin >> color[i];
		}
		for (int i = 0; i < m; i++)
		{
			int a, b;
			cin >> a >> b;
			Union(a, b);
			flag[a] = 1;
			flag[b] = 1;
		}
		//show(n);

		int res = 0;
		for (int i = 1; i <= n; i++)
		{
			if (flag[i])
			{
				int temp[20050];
				int temp_point = 0;
				//cout << " i:" << i << endl;
				for (int j = i; j <= n; j++)
				{
					if (findFarther(i) == findFarther(j))
					{
						temp[temp_point] = j;
						temp_point++;
						flag[j] = 0;
					}
				}

				/*for (int j = 0; j < temp_point; j++)
				{
					cout << temp[j] << ' ';
				}
				cout << endl;*/
				int col[20010] = { 0 };
				int max = 0;
				for (int j = 0; j < temp_point; j++)
				{
					col[color[temp[j]]]++;
					if (col[color[temp[j]]])
					{
						max = col[color[temp[j]]];
					}
				}
				//cout << "max=" << max << endl;
				/*

							for (int j = 0; j < temp_point; j++)
							{
								temp[j] = color[temp[j]];
							}
							sort(temp, temp + temp_point);
							int max = 0;
							int temp_max = 1;

							for (int j = 1; j < temp_point; j++)
							{
								if (temp[j] != temp[j - 1]) temp_max = 0;
								temp_max++;
								if (temp_max > max)
									max = temp_max;
							}*/

				res += temp_point - max;
			}
		}
		cout << res << endl;
	}
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<cstdlib>
#include<map>
#include<cmath>
using namespace std;
int n,m,k;
int c[200010],tot[200010],maxn[200010],col[200010];
int fa[200010];
int x,y,ans=0;
vector<int> a[200010];
int find(int x){
    if(fa[x]==x) return x;
    else return fa[x]=find(fa[x]);
}
int main(){
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&c[i]);
        fa[i]=i;
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        int p=find(x),q=find(y);
        if(p!=q){
            fa[p]=q;
        }
    }
    for(int i=1;i<=n;i++){
        int p=find(i);
        if(p!=i){
            a[p].push_back(i);
        }
    }
    for(int i=1;i<=n;i++){
        int p=find(i);
        if(p==i){
            for(int j=0;j<a[i].size();j++){
                col[c[a[i][j]]]=0;
            }
            maxn[i]=col[c[i]]=1;
            for(int j=0;j<a[i].size();j++){
                col[c[a[i][j]]]++;
                maxn[i]=max(col[c[a[i][j]]],maxn[i]);
                tot[i]++;
            }
            tot[i]+=1;
            ans+=tot[i]-maxn[i];
        }
    }
    cout<<ans;
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<cstdlib>
#include<map>
#include<cmath>
using namespace std;
int fa[200050],tot[200010]={0};
int n,m,k;
int col[200010]={0};
int res=0;
vector<int> a[200010];
int color[200010];
int find(int i)
{
	if(fa[i]==i) return i;
	else
		return fa[i]=find(fa[i]);
}

int main()
{

	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>color[i];
		fa[i]=i;
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		int p=find(x);
		int q=find(y);
		if(p!=q)
		{
			fa[p]=q;
		}
	}
	for(int i=1;i<=n;i++)
	{
		int p=find(i);
		if(p!=i)
		{
			a[p].push_back(i);
		}
	}
	for(int i=1;i<=n;i++)
	{

		int p=find(i);
		if(p==i)
		{

			int max=0;
			for(int j=0;j<a[i].size();j++){
                col[color[a[i][j]]]=0;
            }
            max=col[color[i]]=1;
			for(int j=0;j<a[i].size();j++)
			{
				col[color[a[i][j]]]++;
				if(col[color[a[i][j]]]>max)
					max=col[color[a[i][j]]];
				tot[i]++;
			}
			tot[i]++;
			res+=tot[i]-max;
		}
	}
	cout<<res<<endl;
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<cstdlib>
#include<map>
#include<cmath>
using namespace std;
int fa[200050],tot[200010]={0};
int n,m,k;
int col[200010]={0};
int res=0;
vector<int> a[200010];
int color[200010];
int find(int i)
{
	if(fa[i]==i) return i;
	else
		return fa[i]=find(fa[i]);
}

int main()
{

	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>color[i];
		fa[i]=i;
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		int p=find(x);
		int q=find(y);
		if(p!=q)
		{
			fa[p]=q;
		}
	}
	for(int i=1;i<=n;i++)
	{
		int p=find(i);
		if(p!=i)
		{
			a[p].push_back(i);
		}
	}
	for(int i=1;i<=n;i++)
	{

		int p=find(i);
		if(p==i)
		{
			int max=0;

			 for(int j=0;j<a[i].size();j++){
                col[color[a[i][j]]]=0;
            }
             max=col[color[i]]=1;
			for(int j=0;j<a[i].size();j++)
			{
				col[color[a[i][j]]]++;
				if(col[color[a[i][j]]]>max)
					max=col[color[a[i][j]]]++;
				tot[i]++;
			}
			tot[i]++;
			res+=tot[i]-max;
		}
	}
	cout<<res<<endl;
	return 0;
}


#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int n, fa[200050], am[200050];
int m, k;
int color[200050];
void init()
{
	for (int i = 1; i<=n; i++)
	{
		color[i] = 0;
		fa[i] = i;
		am[i] = 1;
	}
}
/*int findFarther(int x)
{
	while (fa[x] != x) {
		x = fa[x];
	}
	return x;
}*/

int findFarther(int v)      //找元素所在集合的代表元(因为用了路径压缩，路径压缩的主要目的是为了尽快的确定元素所在的集合）
{
	int t1, t2 = v;
	while (v != fa[v])
		v = fa[v];
	while (t2 != fa[t2])        //这里优化的思路还是路径压缩（进一步的在查找函数执行的过程中压缩路径），很神奇!
	{
		t1 = fa[t2];
		fa[t2] = v;
		t2 = t1;
	}
	return v;
}
void Union(int x, int y)
{
	int rootx = findFarther(x), rooty = findFarther(y);
	if (rootx != rooty) {
		if (am[rootx]>am[rooty]) {
			fa[rooty] = rootx;
			am[rootx] += am[rooty];
		}
		else {
			fa[rootx] = rooty;
			am[rooty] += am[rootx];
		}
	}
}

void show(int x)
{
	for (int i = 1; i <= x; i++)
	{
		cout << findFarther(i) << ' ';
	}
	cout << endl;
}

int main()
{

	while (cin >> n >> m >> k)
	{
		int flag[200050] = { 0 };
		init();
		for (int i = 1; i <= n; i++)
		{
			cin >> color[i];
		}
		for (int i = 0; i < m; i++)
		{
			int a, b;
			cin >> a >> b;
			Union(a, b);
			flag[a] = 1;
			flag[b] = 1;
		}
		//show(n);

		int res = 0;
		for (int i = 1; i <= n; i++)
		{
			int temp[20050];
			int temp_point = 0;
			if (flag[i])
			{
				for (int j = i; j <= n; j++)
				{
					if (findFarther(i) == findFarther(j))
					{
						temp[temp_point] = j;
						temp_point++;
						flag[j] = 0;
					}
				}
			}
			int col[20010] = { 0 };
			int max = 0;
			for (int j = 0; j < temp_point; j++)
			{
				col[temp[j]]++;
				if (col[temp[j]]>max)
				{
					max = col[temp[j]];
				}
			}

			/*
			for (int j = 0; j < temp_point; j++)
			{
				temp[j] = color[temp[j]];
			}
			sort(temp, temp + temp_point);
			int max = 0;
			int temp_max = 1;

			for (int j = 1; j < temp_point; j++)
			{
				if (temp[j] != temp[j - 1]) temp_max = 0;
				temp_max++;
				if (temp_max > max)
					max = temp_max;
			}*/

			res += temp_point - max;
		}
		cout << res << endl;
	}
    return 0;
}


#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int n, fa[200], am[200];
int m, k;
int color[200050];
void init()
{
	for (int i = 1; i<=n; i++)
	{
		color[i] = 0;
		fa[i] = i;
		am[i] = 1;
	}
}
int findFarther(int x)
{
	while (fa[x] != x) {
		x = fa[x];
	}
	return x;
}

void Union(int x, int y)
{
	int rootx = findFarther(x), rooty = findFarther(y);
	if (rootx != rooty) {
		if (am[rootx]>am[rooty]) {
			fa[rooty] = rootx;
			am[rootx] += am[rooty];
		}
		else {
			fa[rootx] = rooty;
			am[rooty] += am[rootx];
		}
	}
}

void show(int x)
{
	for (int i = 1; i <= x; i++)
	{
		cout << findFarther(i) << ' ';
	}
	cout << endl;
}

int main()
{

	while (cin >> n >> m >> k)
	{
		int flag[200050] = { 0 };
		init();
		for (int i = 1; i <= n; i++)
		{
			cin >> color[i];
		}
		for (int i = 0; i < m; i++)
		{
			int a, b;
			cin >> a >> b;
			Union(a, b);
			flag[a] = 1;
			flag[b] = 1;
		}
		//show(n);

		int res = 0;
		for (int i = 1; i <= n; i++)
		{
			int temp[20050];
			int temp_point = 0;
			if (flag[i])
			{
				for (int j = i; j <= n; j++)
				{
					if (findFarther(i) == findFarther(j))
					{
						temp[temp_point] = j;
						temp_point++;
						flag[j] = 0;
					}
				}
			}
			for (int j = 0; j < temp_point; j++)
			{
				temp[j] = color[temp[j]];
			}
			sort(temp, temp + temp_point);
			int max = 0;
			int temp_max = 1;

			for (int j = 1; j < temp_point; j++)
			{
				if (temp[j] != temp[j - 1]) temp_max = 0;
				temp_max++;
				if (temp_max > max)
					max = temp_max;
			}
			res += temp_point - max;
		}
		cout << res << endl;
	}
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<cstdlib>
#include<map>
#include<cmath>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k;
int c[200010],tot[200010],maxn[200010],col[200010];
int fa[200010];
int x,y,ans=0;
vector<int> a[200010];
int find(int x){
    if(fa[x]==x) return x;
    else return fa[x]=find(fa[x]);
}
int main(){
    #ifdef lwy
    //  freopen("1.txt","r",stdin);
    #endif
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&c[i]);
        fa[i]=i;
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        int p=find(x),q=find(y);
        if(p!=q){
            fa[p]=q;
        }
    }
    for(int i=1;i<=n;i++){
        int p=find(i);
        if(p!=i){
            a[p].push_back(i);
        }
    }
    for(int i=1;i<=n;i++){
        int p=find(i);
        if(p==i){
            for(int j=0;j<a[i].size();j++){
                col[c[a[i][j]]]=0;
            }
            maxn[i]=col[c[i]]=1;
            for(int j=0;j<a[i].size();j++){
                col[c[a[i][j]]]++;
                maxn[i]=max(col[c[a[i][j]]],maxn[i]);
                tot[i]++;
            }
            tot[i]+=1;
            ans+=tot[i]-maxn[i];
        }
    }
    cout<<ans;
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<cstdlib>
#include<map>
#include<cmath>
using namespace std;
int fa[200050],tot[200010]={0};
int n,m,k;
int col[200010]={0};
int res=0;
vector<int> a[200010];
int color[200010];
int find(int i)
{
	if(fa[i]==i) return i;
	else
		return fa[i]=find(fa[i]);
}

int main()
{

	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>color[i];
		fa[i]=i;
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		int p=find(x);
		int q=find(y);
		if(p!=q)
		{
			fa[p]=q;
		}
	}
	for(int i=1;i<=n;i++)
	{
		int p=find(i);
		if(p!=i)
		{
			a[p].push_back(i);
		}
	}
	for(int i=1;i<=n;i++)
	{

		int p=find(i);
		if(p==i)
		{
			int max=0;

			 for(int j=0;j<a[i].size();j++){
                col[c[a[i][j]]]=0;
            }
             max=col[color[i]]=1;
			for(int j=0;j<a[i].size();j++)
			{
				col[color[a[i][j]]]++;
				if(col[color[a[i][j]]]>max)
					max=col[color[a[i][j]]]++;
				tot[i]++;
			}
			tot[i]++;
			res+=tot[i]-max;
		}
	}
	cout<<res<<endl;
	return 0;
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}

void solve()
{
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     ae(x,y);
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        vector<int> v;
        for(j=0;j<k;j++)
          v.pb(col[con[j]]);
        sort(v.begin(),v.end());
        int mx=0;
        int in=v[0];
        int s=1;
        for(i=1;i<v.size();i++)
        {
          if(v[i]==v[i-1])
            s++;
          else
          {
            if(m<s)
            {
              in=v[i];
              m=s;
            }
          }
        }
        ans+=v.size()-count(v.begin(),v.end(),in);
     }
   }
   printf("%d",ans);
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
int v[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}
void solve()
{
  map<pair<int,int>,bool > M;
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     if(x>y)
      swap(x,y);
     if(M[{x,y}]==0)
     {
       ae(x,y);
       M[{x,y}]=1;
     }
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        if(k==1)
          continue;
        int sz=0;
        for(j=0;j<k;j++)
         {
           v[sz++]=(col[con[j]]);
         }
        int in=v[0],m=1,s=1;
        for(j=1;j<sz;j++)
        {
          if(v[j]==v[j-1])
            s++;
          else
          {
            if(m<s)
            {
              m=s;
              in=v[j-1];
            }
            s=1;
          }
        }
        ans+=sz-count(v,v+sz,in);
     }
   }
   printf("%d",ans);
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
int v[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}
void solve()
{
  map<pair<int,int>,bool > M;
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     if(x>y)
      swap(x,y);
     if(M[{x,y}]==0)
     {
       ae(x,y);
       M[{x,y}]=1;
     }
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        if(k==1)
          continue;
        int sz=0;
        for(j=0;j<k;j++)
         {
           v[sz++]=(col[con[j]]);
         }
        int in=v[0],m=1,s=1;
        for(j=1;j<sz;j++)
        {
          if(v[j]==v[j-1])
            s++;
          else
          {
            if(m<s)
            {
              m=s;
              in=v[j-1];
            }
            s=0;
          }
        }
        ans+=sz-count(v,v+sz,in);
     }
   }
   printf("%d",ans);
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
int v[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}
void solve()
{
  map<pair<int,int>,bool > M;
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     if(x>y)
      swap(x,y);
     if(M[{x,y}]==0)
     {
       ae(x,y);
       M[{x,y}]=1;
     }
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        if(k==1)
          continue;
        int sz=0;
        for(j=0;j<k;j++)
         {
           v[sz++]=(col[con[j]]);
         }
        int in=v[0],m=1,s=1;
        for(j=1;j<sz;j++)
        {
          if(v[j]==v[j-1])
            s++;
          else
          {
            if(m<s)
            {
              m=s;
              in=v[j-1];
            }
            s=1;
          }
        }
        if(m<s)
            {
              m=s;
              in=v[j-1];
            }
        ans+=sz-count(v,v+sz,in);
     }
   }
   printf("%d",ans);
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
int v[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}
void solve()
{
  map<pair<int,int>,bool > M;
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     if(x>y)
      swap(x,y);
     if(M[{x,y}]==0)
     {
       ae(x,y);
       M[{x,y}]=1;
     }
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        if(k==1)
          continue;
        int sz=0;
        for(j=0;j<k;j++)
         {
           v[sz++]=(col[con[j]]);
         }
        int in=v[0],m=1,s=1;
        for(j=1;j<sz;j++)
        {
          if(v[j]==v[j-1])
            s++;
          else
          {
            if(m<s)
            {
              m=s;
              in=v[j];
            }
            s=0;
          }
        }
        ans+=sz-count(v,v+sz,in);
     }
   }
   printf("%d",ans);
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
int v[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}
void solve()
{
  map<pair<int,int>,bool > M;
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     if(x>y)
      swap(x,y);
     if(M[{x,y}]==0)
     {
       ae(x,y);
       M[{x,y}]=1;
     }
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        if(k==1)
          continue;
        int sz=0;
        for(j=0;j<k;j++)
         {
           v[sz++]=(col[con[j]]);
         }
        int in=v[0],m=1,s=1;
        for(j=1;j<sz;j++)
        {
          if(v[j]==v[j-1])
            s++;
          else
          {
            if(m<s)
            {
              m=s;
              in=v[j];
            }
          }
        }
        ans+=sz-count(v,v+sz,in);
     }
   }
   printf("%d",ans);
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
int v[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}

void solve()
{
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     ae(x,y);
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        int sz=0;
        for(j=0;j<k;j++)
          v[sz++]=(col[con[j]]);
        sort(v,v+sz);
        int mx=0;
        int in=v[0];
        int s=1;
        for(i=1;i<sz;i++)
        {
          if(v[i]==v[i-1])
            s++;
          else
          {
            if(m<s)
            {
              in=v[i];
              m=s;
            }
          }
        }
        ans+=sz-count(v,v+sz,in);
     }
   }
   printf("%d",ans);
}


using namespace std;
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=200001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  cin>>t;
  rep(i,1,t)
  {
    solve();
  }
  return 0;
}

int col[mx];
vector<int> g[mx];
bool vis[mx];
int v[mx];
void ae(int u,int v)
{
  g[u].pb(v);
  g[v].pb(u);
}
int k;
int con[mx];
void dfs(int u)
{
   vis[u]=true;
   con[k++]=u;
   for(int i=0;i<g[u].size();i++)
   {
      int w=g[u][i];
      if(!vis[w])
      dfs(w);
   }
}
void solve()
{
  map<pair<int,int>,bool > M;
   int n,m,i,j,x,y;
   scanf("%d%d%d",&n,&m,&k);
   rep(i,1,n)
    scanf("%d",&col[i]);
   while(m--)
   {
     scanf("%d%d",&x,&y);
     if(x>y)
      swap(x,y);
     if(M[{x,y}]==0)
     {
       ae(x,y);
       M[{x,y}]=1;
     }
   }
   int ans=0;
   memset(vis,false,sizeof vis);
   rep(i,1,n)
   {
     if(!vis[i])
     {
        k=0;
        dfs(i);
        if(k==1)
          continue;
        int sz=0;
        for(j=0;j<k;j++)
         {
           v[sz++]=(col[con[j]]);
         }
         sort(v,v+sz);
        int in=v[0],m=1,s=1;
        for(j=1;j<sz;j++)
        {
          if(v[j]==v[j-1])
            s++;
          else
          {
            if(m<s)
            {
              m=s;
              in=v[j-1];
            }
            s=1;
          }
        }
        if(m<s)
            {
              m=s;
              in=v[j-1];
            }
        ans+=sz-count(v,v+sz,in);
     }
   }
   printf("%d",ans);
}


#include <bits/stdc++.h>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            colors.resize(nColor+1);
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            colors.erase(colors.begin(),colors.end());
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <algorithm>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
    return;
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor+1);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];

    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            std::fill(colors.begin(), colors.end(), 0);
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            colors.clear();
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor+1);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            colors.resize(nColor);
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            colors.clear();
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <algorithm>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
    return;
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor+1);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            std::fill(colors.begin(), colors.end(), 0);
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
map<int,int> colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            colors.clear();
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string.h>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
    return;
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor+1);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            memset(&colors[0], 0, colors.size()*sizeof(colors[0]));
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <algorithm>

#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]-1];
    for(int i = 0; i<adjList[index].size(); ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
    return;
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];

    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            std::fill(colors.begin(), colors.end(), 0);
            dfs(i);
            ans+=nNodes-*max_element(colors.begin(),colors.end());
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string.h>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
map<int,int> colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor+1);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            colors.clear();
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]-1];
    maxColor = max(maxColor, colors[socks[index]-1);
    for(int i = 0; i<adjList[index].size(); ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
    return;
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];

    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            std::fill(colors.begin(), colors.end(), 0);
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
vi colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]-1];
    maxColor = max(maxColor, colors[socks[index]-1]);
    for(int i = 0; i<adjList[index].size(); ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
    return;
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];

    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            std::fill(colors.begin(), colors.end(), 0);
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>

#define max(a,b) a>b?a:b

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vvi adjList;
bool visited[200010] {false};
map<int,int> colors;
vi socks;
int nNodes = 0;
int maxColor;

void dfs(int index)
{
    visited[index]=true;
    ++nNodes;
    ++colors[socks[index]];
    maxColor = max(maxColor, colors[socks[index]]);
    int length = adjList[index].size();
    for(int i = 0; i<length; ++i)
        if(!visited[adjList[index][i]])
        {
            dfs(adjList[index][i]);
        }
}

int main()
{
    int nSocks, days, nColor;
    cin>>nSocks>>days>>nColor;
    adjList.resize(nSocks);
    colors.resize(nColor+1);
    socks.resize(nSocks);
    for(int i = 0; i<nSocks; ++i)
        cin>>socks[i];
    if(days==0) {cout<<0; return 0;}
    for(int i = 1; i<=days; ++i)
    {
        int a, b;
        cin>>a>>b;
        --a, --b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i<nSocks; ++i)
    {
        if(!visited[i])
        {
            nNodes = 0;
            maxColor=0;
            dfs(i);
            ans+=nNodes-maxColor;
            colors.clear();
        }
    }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,int> cur;
vector <int> avail[200001];
bool color[200001];
int n, m, k, a[200001], i, c, b, v, ans = 0, visited, maxi;
void visit(int u)
{
    visited++;
    color[u] = 1;
    maxi = max(maxi, ++cur[a[u]]);
    for (int v: avail[u]) if (!color[v]) visit(v);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (!color[i])
        {
            visited = maxi = 0;
            visit(i);
            ans += visited - maxi;
            cur.clear();
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#define ll long long
using namespace std;
vector <vector <int>> avail(200001, vector <int>(0));
vector <int> cur;
int n, color[200001], m, k, a[200001], i, c, b, v, maxi;
ll ans = 0, visited;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.resize(200010,0);
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,ll> cur;
vector <vector <int>> avail(200001, vector <int>(0));
int n, color[200001], m, k, a[200001], i, c, b, v;
ll ans = 0, visited, maxi;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.clear();
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,ll> cur;
vector <vector <int>> avail(200001, vector <int>(0));
ll n, color[200001], m, k, a[200001], i, c, b, v, ans = 0, visited, maxi;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.clear();
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,ll> cur;
vector <int> avail[200001];
bool color[200001];
ll n,  m, k, a[200001], i, c, b, v, ans = 0, visited, maxi;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v: g[u]) if (!(color[v])) visit(v);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.clear();
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#define ll long long
using namespace std;
vector <vector <int>> avail(200001, vector <int>(0));
int cur[200001], maxi, n, visited, color[200001], m, k, a[200001], i, c, b, v;
ll ans = 0;
int index(int a, int b)
{
    return (200000*a + b);
}
int index2(int a, int b)
{
    return (200000*b + a);
}
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi,cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
    color[u] = 2;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            memset(cur,0,sizeof(cur));
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,int> cur;
vector <vector <int>> avail(200001, vector <int>(0));
int n, color[200001], m, k, a[200001], i, c, b, v, maxi;
ll ans = 0, visited;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.clear();
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <ios>
#include <limits.h>
#include <map>
#include <string.h>
#define ll long long
using namespace std;
map <ll,bool> avail;
ll cur[200001], ans = 0, maxi, n, visited, color[200001], m, k, a[200001], i, c, b;
ll index(int a, int b)
{
    return (200000*a + b);
}
ll index2(int a, int b)
{
    return (200000*b + a);
}
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi,cur[a[u]]);
    for (int v = 1; v <= n; v++)
        if (avail[index(u,v)] && color[v] == 0) visit(v);
    color[u] = 2;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[index(c,b)] = 1;
        avail[index2(c,b)] = 1;
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            memset(cur,0,sizeof(cur));
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,ll> cur;
vector <vector <int>> avail(200001, vector <int>(0));
ll n, color[200001], m, k, a[200001], i, c, b, v, ans = 0, visited, maxi;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.clear();
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,ll> cur;
vector <vector <int>> avail(200001, vector <int>(0));
ll n, color[200001], m, k, a[200001], i, c, b, v, ans = 0, visited, maxi;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.clear();
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#define ll long long
using namespace std;
map <int,int> cur;
vector <int> avail[200001];
bool color[200001];
int n, m, k, a[200001], i, c, b, v, ans = 0, visited, maxi;
void visit(int u)
{
    visited++;
    color[u] = 1;
    maxi = max(maxi, ++cur[a[u]]);
    for (int v: avail[u]) if (!color[v]) visit(v);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (!color[i])
        {
            cur.clear();
            visited = maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#define ll long long
using namespace std;
vector <vector <int>> avail(200001, vector <int>(0));
vector <int> cur;
int n, color[200001], m, k, a[200001], i, c, b, v, maxi;
ll ans = 0, visited;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi, cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.resize(200001,0);
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include <iostream>
#include <string.h>
#include <vector>
#define ll long long
using namespace std;
vector <vector <int>> avail(200001, vector <int>(0));
vector <int> cur;
int n, color[200001], m, k, a[200001], i, c, b, v;
ll ans = 0, maxi, visited;
void visit(int u)
{
    visited++;
    color[u] = 1;
    cur[a[u]]++;
    maxi = max(maxi,cur[a[u]]);
    for (v = 0; v < avail[u].size(); v++)
        if (color[avail[u][v]] == 0) visit(avail[u][v]);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    for (i = 1; i <= n; i++) cin>>a[i];
    for (i = 1; i <= m; i++)
    {
        cin>>c>>b;
        avail[c].push_back(b);
        avail[b].push_back(c);
    }
    for (i = 1; i <= n; i++)
        if (color[i] == 0)
        {
            cur.resize(200001,0);
            visited = 0;
            maxi = 0;
            visit(i);
            ans += visited - maxi;
        }
    cout<<ans;
}


#include "cstdio"
int F[200010];
void init(int n){
    for(int i=1;i<=n;i++) F[i]=i;
}
int Found(int x){
    if(F[x]==x) return x;
    return F[x]=Found(F[x]);
}
void Union(int x,int y){
    int nx=Found(x); int ny=Found(y);
    if(nx!=ny)
        F[ny]=nx;
}
int c[200010];
int maxx[200010];
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    init(n);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        Union(a,b);
    }
    int t=0;
    for(int i=1;i<=n;i++){
        if(F[i]==i)
            maxx[++t]=i;
    }
    int sum=0;
    for(int i=1;i<=t;i++){
        int col=maxx[i];
        for(int j=1;j<=n;j++){
            if(F[j]==col&&c[j]!=c[col]){
                sum++; c[j]=c[col];
            }
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
#include "cstring"
#include "map"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
int coler[200010];
bool vis[200010];
bool vis1[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    coler[c[u]]++;
    maxx=max(coler[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v]){
            DFS(v);
        }
    }
}
void DFS1(int u){
    //    printf("%d\n",u);
    vis1[u]=true;
//    sum1++;
    coler[c[u]]=0;
//    maxx=max(coler[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis1[v]){
            DFS(v);
            coler[c[v]]=0;
        }
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            sum1=0; maxx=0;
            DFS(i);
//            printf("%d %d~~\n",sum1,maxx);
            sum=sum+(sum1-maxx);
            DFS1(i);
//            memset(coler, 0, sizeof(coler));
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
#include "cstring"
#include "map"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
int coler[200010];
bool vis[200010];
bool vis1[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    coler[c[u]]++;
    maxx=max(coler[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v]){
            DFS(v);
        }
    }
}
void DFS1(int u){
    vis1[u]=true;
    coler[c[u]]=0;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis1[v])
            DFS1(v);
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            sum1=0; maxx=0;
            DFS(i); DFS1(i);
//           printf("%d %d~~\n",sum1,maxx);
            sum=sum+(sum1-maxx);
//            memset(coler, 0, sizeof(coler));
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int maxn=233333;

int a[maxn];

int f[maxn];

int n,m,k;

int findfa(int x)
{
	return f[x]==x?x:f[x]=findfa(f[x]);
}

void uni(int x,int y)
{
	f[findfa(x)]=findfa(y);
}

vector <int> vis[maxn];

int cnt[maxn];

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		f[i]=i;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		uni(x,y);
	}
	for(int i=1;i<=n;i++)
		vis[findfa(i)].push_back(a[i]);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int tmp=0;
		for(int j=0;j<vis[i].size();j++)
		{
			cnt[vis[i][j]]++;
			tmp=max(tmp,cnt[vis[i][j]]);
		}
		for(int j=0;j<vis[i].size();j++)
			cnt[vis[i][j]]--;
		ans+=vis[i].size()-tmp;
	}
	printf("%d",ans);
}


#include "cstdio"
#include "algorithm"
#include "vector"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
int coler[200010];
bool vis[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    coler[c[u]]++;
    maxx=max(coler[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v])
            DFS(v);
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            memset(coler,0,sizeof(coler));
            sum1=0;  maxx=0;
            DFS(i);
//            printf("%d %d\n",sum1,maxx);
            sum=sum+(sum1-maxx);
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
#include "cstring"
#include "map"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
int coler[200010];
bool vis[200010];
bool vis1[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    coler[c[u]]++;
    maxx=max(coler[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v]){
            DFS(v);
        }
    }
}
void DFS1(int u){
    coler[c[u]]=0; vis1[u]=true;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis1[v]){
            DFS(v);
        }
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            sum1=0; maxx=0;
            DFS(i);
//            printf("%d %d\n",sum1,maxx);
            sum=sum+(sum1-maxx);
            DFS1(i);
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
#include "cstring"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
int coler[200010][200010];
bool vis[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int i,int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    coler[i][c[u]]++;
    maxx=max(coler[i][c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v]){
            DFS(i,v);
        }
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            sum1=0; maxx=0;
            DFS(i,i);
//            printf("%d %d\n",sum1,maxx);
            sum=sum+(sum1-maxx);
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
using namespace std;
int F[200010];
int c[200010];
int sum;
vector<int> G[200010];
int coler[200010];
bool vis[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int n,int u){
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v]){
            if(c[n]!=c[v]){
                sum++; c[v]=c[n];
            }
            vis[v]=true;
            DFS(n,v);
        }
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    int maxx=0, t=0;
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        coler[c[a]]++; coler[c[b]]++;
        if(maxx<coler[c[a]]){
            maxx=coler[c[a]]; t=a;
        }
        if(maxx<coler[c[b]]){
            maxx=coler[c[b]]; t=b;
        }
        G[a].push_back(b); G[b].push_back(a);
    }
    DFS(c[t],t);
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
int F[200010];
int c[200010];
int sum;
void init(int n){
    for(int i=1;i<=n;i++) F[i]=i;
}
int Found(int x){
    if(F[x]==x) return x;
    return F[x]=Found(F[x]);
}
void Union(int x,int y){
    int nx=Found(x); int ny=Found(y);
    if(nx!=ny){
        F[ny]=nx;
        if(c[ny]!=c[nx]){
            c[ny]=c[nx]; sum++;
        }
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    init(n);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        Union(a,b);
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
int coler[200010];
bool vis[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    coler[c[u]]++;
    maxx=max(coler[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v])
            DFS(v);
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            for(int i=1;i<=k;i++)
                coler[i]=0;
            sum1=0;  maxx=0;
            DFS(i);
//            printf("%d %d\n",sum1,maxx);
            sum=sum+(sum1-maxx);
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
#include "cstring"
#include "map"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
map<int,int>Map;
bool vis[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    Map[c[u]]++;
    maxx=max(Map[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v]){
            DFS(v);
        }
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            sum1=0; maxx=0;
            Map.clear();
            DFS(i);
//            printf("%d %d\n",sum1,maxx);
            sum=sum+(sum1-maxx);
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include "cstdio"
#include "algorithm"
#include "vector"
#include "cstring"
using namespace std;
int F[200010];
int c[200010];
int sum;
int sum1;
int maxx;
vector<int> G[200010];
int coler[200010];
bool vis[200010];
bool cmp(int a,int b){
    return a>b;
}
void DFS(int u){
//    printf("%d\n",u);
    vis[u]=true;
    sum1++;
    coler[c[u]]++;
    maxx=max(coler[c[u]],maxx);
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!vis[v])
            DFS(v);
    }
}
int main(){
    int n,m,k; scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        G[a].push_back(b); G[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            memset(coler,0,sizeof(coler));
            sum1=0;  maxx=0;
            DFS(i);
//            printf("%d %d\n",sum1,maxx);
            sum=sum+(sum1-maxx);
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];
ll sz[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    if(getdsu(a) == getdsu(b)) {
        return;
    }
    if(sz[p[getdsu(a)]] > sz[p[getdsu(b)]]) {
        sz[p[a]] += sz[p[b]];
        p[p[b]] = p[p[a]];
    } else {
        sz[p[b]] += sz[p[a]];
        p[p[a]] = p[p[b]];
    }
}

vector <ll> g[MAXN];

bool used[MAXN];

int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        mergedsu(from, to);
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[getdsu(p[i])]].pb(color[i]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]]++;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];
        vector <ll> clrs(k + 1, 0);
        ll mx = 0;
        for(int j = 0; j < g[t].size(); j++) {
            clrs[g[t][j]]++;
            mx = max(clrs[g[t][j]], mx);
        }
        ans += g[t].size() - mx;
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    p[getdsu(a)] = p[getdsu(b)];
    getdsu(a);
}

vector <ll> g[MAXN];

int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        mergedsu(from, to);
    }
    for(int i = 1; i <= n; i++) {
        getdsu(i);
    }
    for(int i = 1; i <= n; i++) {
        g[p[i]].pb(color[i]);
    }
    for(int i = 1; i <= n; i++) {
        if(p[i] == i) {
            vector <ll> clrs(k + 1, 0);
            ll mx = 0;
            for(int j = 0; j < g[i].size(); j++) {
                clrs[g[i][j]]++;
                mx = max(clrs[g[i][j]], mx);
            }
            ans += g[i].size() - mx;
        }
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];
ll sz[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    if(sz[p[getdsu(a)]] > sz[p[getdsu(b)]]) {
        sz[p[a]] += sz[p[b]];
        p[p[b]] = p[p[a]];
    } else {
        sz[p[b]] += sz[p[a]];
        p[p[a]] = p[p[b]];
    }
}

vector <ll> g(MAXN);
ll mxs[MAXN];
map <ll, map<ll, ll> > ams;
bool used[MAXN];

int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        mergedsu(from, to);
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[getdsu(p[i])]]++;
        ams[p[i]][color[i]]++;
        mxs[p[i]] = max(mxs[p[i]], ams[p[i]][color[i]]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]] = true;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];
        ans += g[t] - mxs[t];
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];
ll sz[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    if(sz[p[getdsu(a)]] > sz[p[getdsu(b)]]) {
        sz[p[a]] += sz[p[b]];
        p[p[b]] = p[p[a]];
    } else {
        sz[p[b]] += sz[p[a]];
        p[p[a]] = p[p[b]];
    }
}

vector <ll> g(MAXN);
ll mxs[MAXN];
map <ll, map<ll, ll> > ams;
bool used[MAXN];
map <ll, map<ll, bool> > was;
int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        if(!was[from][to] && !was[to][from]) {
            mergedsu(from, to);
        }
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[getdsu(p[i])]]++;
        ams[p[i]][color[i]]++;
        mxs[p[i]] = max(mxs[p[i]], ams[p[i]][color[i]]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]] = true;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];
        ans += g[t] - mxs[t];
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];
ll sz[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    if(sz[p[getdsu(a)]] > sz[p[getdsu(b)]]) {
        sz[p[a]] += sz[p[b]];
        p[p[b]] = p[p[a]];
    } else {
        sz[p[b]] += sz[p[a]];
        p[p[a]] = p[p[b]];
    }
}

vector <ll> g(MAXN);
vector <ll> mxs(MAXN, 1);
map <ll, map<ll, ll> > ams;
bool used[MAXN];
map <ll, map<ll, bool> > was;
int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        if(!was[from][to] && !was[to][from]) {
            mergedsu(from, to);
        }
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[getdsu(p[i])]]++;
        ams[p[i]][color[i]]++;
        mxs[p[i]] = max(mxs[p[i]], ams[p[i]][color[i]]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]] = true;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];
        ans += g[t] - mxs[t];
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];
ll sz[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    if(sz[p[getdsu(a)]] > sz[p[getdsu(b)]]) {
        sz[p[a]] += sz[p[b]];
        p[p[b]] = p[p[a]];
    } else {
        sz[p[b]] += sz[p[a]];
        p[p[a]] = p[p[b]];
    }
}

vector <ll> g[MAXN];

bool used[MAXN];

int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        mergedsu(from, to);
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[getdsu(p[i])]].pb(color[i]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]]++;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];
        vector <ll> clrs(k + 1, 0);
        ll mx = 0;
        for(int j = 0; j < g[t].size(); j++) {
            clrs[g[t][j]]++;
            mx = max(clrs[g[t][j]], mx);
        }
        ans += g[t].size() - mx;
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back
#include<windows.h>
typedef long long ll;
using namespace std;

const ll MAXN = +200500, INF = 1e18;

vector <ll> g[MAXN];

ll n, m, k;

ll inc[MAXN];
ll color[MAXN];

int main(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        inc[to]++;
        inc[from]++;
        g[from].pb(to);
    }
    ll cnt = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < g[i].size(); j++) {
            if(color[g[i][j]] == color[i]) {
                continue;
            } else {
                if(inc[i] > inc[g[i][j]]) {
                    color[g[i][j]] = color[i];
                } else {
                    color[i] = color[g[i][j]];
                }
                cnt++;
            }
        }
    }
    cout << cnt;
}


#include<bits/stdc++.h>
#define pb push_back
#include<windows.h>
typedef long long ll;
using namespace std;

const ll MAXN = +200500, INF = 1e18;

vector <ll> g[MAXN];

ll n, m, k;

ll inc[MAXN];
ll color[MAXN];

int main(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        inc[to]++;
        inc[from]++;
        g[from].pb(to);
        g[to].pb(from);
    }
    ll cnt = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < g[i].size(); j++) {
            if(color[g[i][j]] == color[i]) {
                continue;
            } else {
                if(inc[i] > inc[g[i][j]]) {
                    color[g[i][j]] = color[i];
                } else {
                    color[i] = color[g[i][j]];
                }
                cnt++;
            }
        }
    }
    cout << cnt;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    p[getdsu(a)] = p[getdsu(b)];
    getdsu(a);
}

vector <ll> g[MAXN];

bool used[MAXN];

int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        mergedsu(from, to);
    }
    for(int i = 1; i <= n; i++) {
        getdsu(i);
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[i]].pb(color[i]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]]++;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];
        vector <ll> clrs(k + 1, 0);
        ll mx = 0;
        for(int j = 0; j < g[t].size(); j++) {
            clrs[g[t][j]]++;
            mx = max(clrs[g[t][j]], mx);
        }
        ans += g[t].size() - mx;
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];
ll sz[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    if(sz[p[getdsu(a)]] > sz[p[getdsu(b)]]) {
        sz[p[a]] += sz[p[b]];
        p[p[b]] = p[p[a]];
    } else {
        sz[p[b]] += sz[p[a]];
        p[p[a]] = p[p[b]];
    }
}

vector <ll> g[MAXN];
ll mxs[MAXN];
map <ll, map<ll, ll> > ams;
bool used[MAXN];

int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        mergedsu(from, to);
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[getdsu(p[i])]].pb(color[i]);
        ams[p[i]][color[i]]++;
        mxs[p[i]] = max(mxs[p[i]], ams[p[i]][color[i]]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]] = true;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];

        ans += g[t].size() - mxs[t];
    }
    cout << ans;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

const ll MAXN = +100500 * 2;
const ll INF = 4e18;

ll used[MAXN];
ll color[MAXN];
ll amc[MAXN];

bool used2[MAXN];

vector <ll> g[MAXN];

ll sz = 0;
ll cur = 1;

ll mx = 0;

void dfs(ll v, ll p) {
    sz++;
    used2[v] = 1;
    if(used[color[v]] != cur) {
        used[color[v]] = cur;
        amc[color[v]] = 1;
    } else amc[color[v]]++;
    for(int i = 0; i < g[v].size(); i++) {
        ll to = g[v][i];
        if(to != p && !used2[to]) {
            dfs(to, v);
        }
    }
    mx = max(mx, amc[color[v]]);
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
    }
    for(int i = 1; i <= m; i++) {
        ll a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!used2[i]) {
            sz = 0;
            mx = 0;
            dfs(i, -1);
            cur++;
            ans += sz - mx;
        }
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back
#include<windows.h>
typedef long long ll;
using namespace std;

const ll MAXN = +200500, INF = 1e18;

vector <ll> g[MAXN];

ll n, m, k;

ll color[MAXN];
ll used[MAXN];

int main(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        g[from].pb(to);
        g[to].pb(from);
    }
    ll cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(used[i] == true) {
            continue;
        }
        ll sz = 0;
        vector <ll> clrs(MAXN, 0);
        queue <ll> q;
        q.push(i);
        ll mx = 0;
        clrs[color[i]]++;
        while(!q.empty()) {
            ll from = q.front();
            used[from] = true;
            for(int j = 0; j < g[from].size(); j++) {
                ll to = g[from][j];
                if(used[to] == false) {
                    clrs[color[to]]++;
                    q.push(to);
                }
            }
            mx = max(mx, clrs[color[from]]);
            q.pop();
            sz++;
        }
        cnt += sz - mx;
    }
    cout << cnt;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

ll color[MAXN];
ll p[MAXN];

ll getdsu(ll a) {
    if(p[a] == a) {
        return a;
    }
    else {
        p[a] = getdsu(p[a]);
        return p[a];
    }
}

void mergedsu(ll a, ll b) {
    p[getdsu(a)] = p[getdsu(b)];
    getdsu(a);
}

vector <ll> g[MAXN];

bool used[MAXN];

int main() {
    srand(time(0));
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
        p[i] = i;
    }
    for(int i = 1; i <= m; i++) {
        ll from, to;
        cin >> from >> to;
        mergedsu(from, to);
    }
    vector <ll> kol;
    for(int i = 1; i <= n; i++) {
        g[p[getdsu(p[i])]].pb(color[i]);
        if(!used[p[i]]) {
            kol.pb(p[i]);
            used[p[i]]++;
        }
    }
    for(int i = 0; i < kol.size(); i++) {
        ll t = kol[i];
        vector <ll> clrs(k + 1, 0);
        ll mx = 0;
        for(int j = 0; j < g[t].size(); j++) {
            clrs[g[t][j]]++;
            mx = max(clrs[g[t][j]], mx);
        }
        ans += g[t].size() - mx;
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long ll;
using namespace std;

const ll MAXN = +200500;
const ll INF = 1e18;

vector <ll> g[MAXN];
ll color[MAXN];
bool used[MAXN];

ll mx = 0;
ll sz = 0;

void dfs(ll st, map <ll, ll> mp) {
    used[st] = true;
    sz++;
    mp[color[st]]++;
    mx = max(mp[color[st]], mx);
    for(int i = 0; i < g[st].size(); i++) {
        if(!used[g[st][i]]) {
            dfs(g[st][i], mp);
        }
    }
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
    }
    for(int i = 1; i <= m; i++) {
        ll to, from;
        cin >> from >> to;
        g[to].pb(from);
        g[from].pb(to);
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) {
            map <ll, ll> mp;
            dfs(i, mp);
            ans += sz - mx;
            mx = 0;
            sz = 0;
        }
    }
    cout << ans;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
vector<vector<int> > all;
void dfs(vector<int> g[],int start, vector<int> &vis,vector<int> &temp){
	if(vis[start])
		return ;
	vis[start]=1;
	temp.push_back(start);
	for(int i=0;i<g[start].size();i++){
		if(!vis[g[start][i]]){
			dfs(g,g[start][i],vis,temp);
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k,u,v;
    cin>>n>>m>>k;
    if(m==0){
	    cout<<0;
	    return 0;
	}
    int clrs[n];
    vector<int> vis(n,0);
    for(int i=0;i<n;i++){
    	cin>>clrs[i];
    	clrs[i]--;
	}
	vector<int> g[n];
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	//cout<<"found\n";
	//find the disconnected components
	for(int i=0;i<n;i++){
	    //cout<<"found\n";
		if(!vis[i]){
		    vector<int> temp;
			dfs(g,i,vis,temp);
			all.pb(temp);
			temp.clear();
			temp.shrink_to_fit();
		}
	}
	//cout<<all.size()<<endl;
	int ans=0;
	for(int i=0;i<all.size();i++){
		vector<int> cnt(k,0);
		int t=INT_MIN;
		for(int j=0;j<all[i].size();j++){
			cnt[clrs[all[i][j]]]++;
			t=max(t,cnt[clrs[all[i][j]]]);
		}
		//cout<<t<<endl;
		ans+=(all[i].size()-t);
	}
	cout<<ans;
 	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
vector<vector<int> > all;
vector<int> temp;
void dfs(vector<int> g[],int start, vector<int> &vis){
	if(vis[start])
		return ;
	vis[start]=1;
	temp.push_back(start);
	for(int i=0;i<g[start].size();i++){
		if(!vis[g[start][i]]){
			dfs(g,g[start][i],vis);
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k,u,v;
    cin>>n>>m>>k;
    int clrs[n];
    vector<int> vis(n,0);
    for(int i=0;i<k;i++){
    	cin>>clrs[i];
	}
	vector<int> g[n];
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	//find the disconnected components
	for(int i=0;i<n;i++){
		if(!vis[i]){
			dfs(g,i,vis);
			if(temp.empty())
			all.pb(temp);
			temp.clear();
			temp.shrink_to_fit();
		}
	}
	//cout<<all.size()<<endl;
	int ans=0;
	for(int i=0;i<all.size();i++){
		vector<int> cnt(k,0);
		int t=INT_MIN;
		for(int j=0;j<all[i].size();j++){
			cnt[clrs[all[i][j]]]++;
			t=max(t,cnt[clrs[all[i][j]]]);
		}
		//cout<<t<<endl;
		ans+=(all[i].size()-t);
	}
	cout<<ans;
 	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
void dfs(vector<int> g[],int start, vector<int> &vis,vector<int> &temp){
	if(vis[start])
		return ;
	vis[start]=1;
	temp.pb(start);
	for(int i=0;i<g[start].size();i++){
		if(!vis[g[start][i]]){
			dfs(g,g[start][i],vis,temp);
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k,u,v;
    cin>>n>>m>>k;
    if(m==0){
	    cout<<0;
	    return 0;
	}
    int clrs[n];
    vector<int> vis(n,0);
    for(int i=0;i<n;i++){
    	cin>>clrs[i];
    	clrs[i]--;
	}
	vector<int> g[n];
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	vector<int> cnt(k,0),ss;
	int ans=0;
	//find the disconnected components
	for(int i=0;i<n;i++){
	    //cout<<"found\n";
		if(!vis[i]){
		    vector<int> temp;
			dfs(g,i,vis,temp);
		    int t=INT_MIN;
		    for(int j=0;j<temp.size();j++){
			    ss.pb(clrs[temp[j]]);
			    cnt[clrs[temp[j]]]++;
			    t=max(t,cnt[clrs[temp[j]]]);
		    }
		    //cout<<t<<endl;
		    ans+=(temp.size()-t);
		    for(int i=0;i<ss.size();i++){
		        cnt[ss[i]]=0;
		    }
		}
	}
	cout<<ans;
 	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
void dfs(vector<int> g[],int start, vector<int> &vis,vector<int> &temp){
	if(vis[start])
		return ;
	vis[start]=1;
	temp.pb(start);
	for(int i=0;i<g[start].size();i++){
		if(!vis[g[start][i]]){
			dfs(g,g[start][i],vis,temp);
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k,u,v;
    cin>>n>>m>>k;
    if(m==0){
	    cout<<0;
	    return 0;
	}
    int clrs[n];
    vector<int> vis(n,0);
    for(int i=0;i<n;i++){
    	cin>>clrs[i];
    	clrs[i]--;
	}
	vector<int> g[n];
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	vector<int> cnt(k,0);
	int ans=0;
	//find the disconnected components
	for(int i=0;i<n;i++){
	    //cout<<"found\n";
		if(!vis[i]){
		    set<int> ss;
		    vector<int> temp;
			dfs(g,i,vis,temp);
		    int t=INT_MIN;
		    for(int j=0;j<temp.size();j++){
			    ss.insert((int)clrs[temp[j]]);
			    cnt[clrs[temp[j]]]++;
			    t=max(t,cnt[clrs[temp[j]]]);
		    }
		    //cout<<t<<endl;
		    ans+=(temp.size()-t);
		    for(auto it=ss.begin();it!=ss.end();it++){
                int x=*it;
                cnt[x]=0;
            }
            ss.clear();
		}
	}
	cout<<ans;
 	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
void dfs(vector<int> g[],int start, vector<int> &vis,vector<int> &temp){
	if(vis[start])
		return ;
	vis[start]=1;
	temp.pb(start);
	for(int i=0;i<g[start].size();i++){
		if(!vis[g[start][i]]){
			dfs(g,g[start][i],vis,temp);
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k,u,v;
    cin>>n>>m>>k;
    if(m==0){
	    cout<<0;
	    return 0;
	}
    int clrs[n];
    vector<int> vis(n,0);
    for(int i=0;i<n;i++){
    	cin>>clrs[i];
    	clrs[i]--;
	}
	vector<int> g[n];
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	int ans=0;
	//find the disconnected components
	for(int i=0;i<n;i++){
	    //cout<<"found\n";
		if(!vis[i]){
		    vector<int> temp;
			dfs(g,i,vis,temp);

			vector<int> cnt(k,0);
		    int t=INT_MIN;
		    for(int j=0;j<temp.size();j++){
			    cnt[clrs[temp[j]]]++;
			    t=max(t,cnt[clrs[temp[j]]]);
		    }
		    //cout<<t<<endl;
		    ans+=(temp.size()-t);
		}
	}
	cout<<ans;
 	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
void dfs(vector<int> g[],int start, vector<int> &vis,vector<int> &temp){
	if(vis[start])
		return ;
	vis[start]=1;
	temp.pb(start);
	for(int i=0;i<g[start].size();i++){
		if(!vis[g[start][i]]){
			dfs(g,g[start][i],vis,temp);
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k,u,v;
    cin>>n>>m>>k;
    if(m==0){
	    cout<<0;
	    return 0;
	}
    int clrs[n];
    vector<int> vis(n,0);
    for(int i=0;i<n;i++){
    	cin>>clrs[i];
    	clrs[i]--;
	}
	vector<int> g[n];
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	vector<int> cnt(k,0);
	int ans=0;
	set<int> ss;
	//find the disconnected components
	for(int i=0;i<n;i++){
	    //cout<<"found\n";
		if(!vis[i]){
		    vector<int> temp;
			dfs(g,i,vis,temp);
		    int t=INT_MIN;
		    for(int j=0;j<temp.size();j++){
			    ss.insert((int)clrs[temp[j]]);
			    cnt[clrs[temp[j]]]++;
			    t=max(t,cnt[clrs[temp[j]]]);
		    }
		    //cout<<t<<endl;
		    ans+=(temp.size()-t);
		    for(auto it=ss.begin();it!=ss.end();it++){
                int x=*it;
                cnt[x]=0;
            }
		}
	}
	cout<<ans;
 	return 0;
}


#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
vector<vector<int> > all;
void dfs(vector<int> g[],int start, vector<int> &vis,vector<int> &temp){
	if(vis[start])
		return ;
	vis[start]=1;
	temp.push_back(start);
	for(int i=0;i<g[start].size();i++){
		if(!vis[g[start][i]]){
			dfs(g,g[start][i],vis,temp);
		}
	}
	return ;
}
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k,u,v;
    cin>>n>>m>>k;
    int clrs[n];
    vector<int> vis(n,0);
    for(int i=0;i<n;i++){
    	cin>>clrs[i];
    	clrs[i]--;
	}
	vector<int> g[n];
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	//cout<<"found\n";
	//find the disconnected components
	for(int i=0;i<n;i++){
	    //cout<<"found\n";
		if(!vis[i]){
		    vector<int> temp;
			dfs(g,i,vis,temp);
			all.pb(temp);
			temp.clear();
			temp.shrink_to_fit();
		}
	}
	//cout<<all.size()<<endl;
	int ans=0;
	for(int i=0;i<all.size();i++){
		vector<int> cnt(k,0);
		int t=INT_MIN;
		for(int j=0;j<all[i].size();j++){
			cnt[clrs[all[i][j]]]++;
			t=max(t,cnt[clrs[all[i][j]]]);
		}
		//cout<<t<<endl;
		ans+=(all[i].size()-t);
	}
	cout<<ans;
 	return 0;
}