#include<bits/stdc++.h>
using namespace std;
vector<int>adj[200005];
int vis[200005],ans;
map<int,int>m1;
int col[200005],k1;
void dfs(int s)
{
    vis[s]=1;
    ans=max(ans,m1[col[s]]);
    for(int i=0;i<(int)adj[s].size();i++)
    {
        k1++;
        if(!vis[adj[s][i]])
        {
            dfs(adj[s][i]);
        }
    }
}
int main()
{
    int n,m,k,a,b,i;
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        cin>>col[i];
    }
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        m1[col[a]]++;
        m1[col[b]]++;
    }
    int sum=0;
    for(i=1;i<=n;i++)
    {
        k1=0;
        ans=0;
        if(!vis[i])
        {
            dfs(i);
            sum+=(k1-ans);
        }
    }
    cout<<sum;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int>adj[200005];
int vis[200005],ans;
map<int,int>m1;
int col[200005],k1;
void dfs(int s)
{
    vis[s]=1;
    m1[col[s]]++;
    k1++;
    ans=max(ans,m1[col[s]]);
    for(int i=0;i<(int)adj[s].size();i++)
    {
        if(!vis[adj[s][i]])
        {
            dfs(adj[s][i]);
        }
    }
}
int main()
{
    int n,m,k,a,b,i;
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        cin>>col[i];
    }
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int sum=0;
    for(i=1;i<=n;i++)
    {
        k1=0;
        ans=0;
        if(!vis[i])
        {
            m1.clear();
            dfs(i);
            sum+=(k1-ans);
        }
    }
    cout<<sum;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997;
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

vector<int>v[200001];
set<int>s;
bool visited[200001]={false};

int a[200001];
void dfs(int st){
	visited[st]=true;
	s.insert(a[st]);
	for(auto i:v[st]){
		if(!visited[i]){
			dfs(i);
		}
	}
}

int main(){
	fastio();
	ll n,m,k;
	cin>>n>>m>>k;

	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		int b,c;
		cin>>b>>c;
		v[b].push_back(c);
		v[c].push_back(b);
	}
	int ans=0;
	for(int i=1;i<=k;i++){
		if(!visited[i]){
			dfs(i);
			ans+=s.size()-1;
			s.clear();
		}
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997;
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int parent[200001];
int si[200001];

void make_parent(int v){
	parent[v]=v;
	si[v]=1;
}

int find_set(int v){
	if(v==parent[v]) return v;
	return find_set(parent[v]);
}

void union_set(int a,int b){
	a= find_set(a);
	b  = find_set(b);
	if(a!=b){
		if(si[b]>si[a]) swap(a,b);
		parent[b]=a;
		si[a]+=si[b];
	}
}

int main(){
	fastio();
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		make_parent(i);
	}
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		union_set(i,a);
	}
	int ans=0;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		if(find_set(a)!=find_set(b)){
			union_set(a,b);
			ans++;
		}
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997;
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

vector<int>v[200001];
bool visited[200001]={false};
int cnt=0;
int a[200001];
map<int,int>f;

void dfs(int s){
	visited[s]=true;
	cnt++;
	f[a[s]]++;
	for(auto i:v[s]) {
		if(!visited[i]) dfs(i);
	}
}

int main(){
	fastio();
	ll n,m,k;
	cin>>n>>m>>k;

	for(int i=1;i<=n;i++) cin>>a[i];

	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			dfs(i);
			int p = INT_MIN;
			for(auto j:f){
				p = max(p,j.second);
			}
			//cout<<cnt<<" "<<p<<" ";

			ans+=(cnt-p);
			cnt=0;
			p=0;
			f.clear();
		}
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997;
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int parent[200001];
int si[200001];

void make_parent(int v,int a){
	parent[v]=a;
	si[v]=1;
}

int find_set(int v){
	if(v==parent[v]) return v;
	return find_set(parent[v]);
}

void union_set(int a,int b){
	a= parent[a];
	b  = parent[b];
	if(a!=b){
		//if(si[b]>si[a]) swap(a,b);
		parent[b]=a;
		//si[a]+=si[b];
	}
}

int main(){
	fastio();
	int n,m,k;
	cin>>n>>m>>k;

	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		make_parent(i,a);
	}
	int ans=0;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		if(parent[a]!=parent[b]){
			// for(int i=1;i<=n;i++) cout<<parent[i]<<" ";
			// cout<<"\n";
			union_set(a,b);
			ans++;
		}
	}
	//for(int i=1;i<=n;i++) cout<<parent[i]<<" ";
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997;
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int parent[200001];
int si[200001];

void make_parent(int v){
	parent[v]=v;
	si[v]=1;
}

int find_set(int v){
	if(v==parent[v]) return v;
	return find_set(parent[v]);
}

void union_set(int a,int b){
	a= find_set(a);
	b  = find_set(b);
	if(a!=b){
		if(si[b]>si[a]) swap(a,b);
		parent[b]=a;
		si[a]+=si[b];
	}
}

int main(){
	fastio();
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		make_parent(i);
	}
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		union_set(i,a);
	}
	int ans=0;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		if(find_set(a)!=find_set(b)) ans++;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997;
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

vector<int>v[200001];
set<int>s;
bool visited[200001]={false};

int a[200001];
void dfs(int st){
	visited[st]=true;
	s.insert(a[st]);
	for(auto i:v[st]){
		if(!visited[i]){
			dfs(i);
		}
	}
}

int main(){
	fastio();
	ll n,m,k;
	cin>>n>>m>>k;

	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		int b,c;
		cin>>b>>c;
		v[b].push_back(c);
		v[c].push_back(b);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!visited[i] && v[i].size()>0){
			dfs(i);
			ans+=(s.size()-1);
			s.clear();
		}
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)
map<ll,ll> mp;
ll mx=0;
bool vis[200050];
vector<ll> adj[200050];
ll col[200050];
ll total;

void dfs(ll u){
    vis[u]=1;
    mp[col[u]]++;
    mx=max(mx,mp[col[u]]);
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            dfs(i);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    f(i,n) cin>>col[i];

    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    ll ans=0;

    for(int i=0;i<n;i++){

        if(!vis[i]) {
            mp.clear();
        	total=0;
        	mx=0;
        	dfs(i);

        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)
map<ll,ll> mp;
ll mx=0;

void dfs(vector<ll> adj[],vector<ll> col,vector<bool> &vis,ll u,ll &total){
    if(vis[u]) return;
    vis[u]=1;
    mp[col[u]]++;
    mx=max(mx,mp[col[u]]);
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            vis[i]=1;
            dfs(adj,col,vis,i,total);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> col(n);
    f(i,n) cin>>col[i];

    vector<ll> adj[n];
    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    vector<bool> vis(n,0);

    ll ans=0;

    for(int i=0;i<n;i++){

        if(!vis[i]) {
            mp.clear();
        	ll total=0;
        	mx=0;
        	dfs(adj,col,vis,i,total);

        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)

void dfs(vector<ll> adj[],vector<ll> col,vector<bool> &vis,map<ll,ll> &mp,ll u,ll &total){
    vis[u]=1;
    mp[col[u]]++;
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            vis[i]=1;
            dfs(adj,col,vis,mp,i,total);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> col(n);
    f(i,n) cin>>col[i];

    vector<ll> adj[n];
    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    vector<bool> vis(n,0);

    ll ans=0;

    for(int i=0;i<n;i++){
        map<ll,ll> mp;
        if(!vis[i]) {
        	ll total=0;
        	dfs(adj,col,vis,mp,i,total);
        	ll mx=0;
        	for(auto ele:mp) if(ele.second>mx) mx=ele.second;
        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int color[200005];
vector <int> adj[200005];
bool visited[2000005];
int maxii;
int consize;
map <int,int> freq;// frequency of color c is f
void dfs(int u){
if(visited[u]==true)
    return ;
visited[u]=true;

consize++;// no of nodes in this cp goes up by 1
freq[color[u]]++;// increase the frequency for this color

maxii=max(maxii,freq[color[u]]);

for(int i=0;i<adj[u].size();i++){
    int v=adj[u][i];// neighbor
    if(visited[v]==true)
        continue;
    dfs(v);
}

}
int main()
{
    int n,m,k;
    memset(visited,false,sizeof(visited));
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++){
            int x;
       scanf("%d",&x);
       color[i]=x;

    }
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(visited[i]==false){
                // for this connected components
                consize=0;
                 maxii=0;
                 freq.clear();

                 dfs(i);// carry out dfs with this vertex

                 ans+=consize-maxii;

        }

    }
   printf("%d\n",ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 200050;

int n, m, k, mx;
int a[MaxN], ans;
int l, r, fa[MaxN], siz[MaxN];
vector<int> G[MaxN];
map<int,int> mp;

//find
int f(int x)
{
    return fa[x] == x?x:fa[x] = f(fa[x]);
}

int main()
{
    FIO
    cin>>n>>m>>k;

    rep(i,1,n) {
        cin>>a[i];
        // father
        fa[i] = i;
    }

    //connecting components
    rep(i,1,m)
    {
        cin>>l>>r;
        if(f(l) != f(r)) fa[f(l)] = f(r);
    }

    rep(i,1,n){
        //calculating size
    	siz[f(i)] ++;
    	// each father : all color
    	G[f(i)].push_back(a[i]);
    }

    rep(i,1,n){

        if(siz[i])
        {

            mp.clear(); mx = 0;

            rep(j,0,G[i].size()-1){

                mp[G[i][j]] ++;
                mx = max(mx, mp[G[i][j]]);

            }

            ans += siz[i] - mx;

        }

    }

    printf("%d",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)
map<ll,ll> mp;
ll mx=0;

void dfs(vector<ll> adj[],vector<ll> col,vector<bool> &vis,ll u,ll &total){
    vis[u]=1;
    mp[col[u]]++;
    mx=max(mx,mp[col[u]]);
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            vis[i]=1;
            dfs(adj,col,vis,i,total);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> col(n);
    f(i,n) cin>>col[i];

    vector<ll> adj[n];
    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    vector<bool> vis(n,0);

    ll ans=0;

    for(int i=0;i<n;i++){

        if(!vis[i]) {
            mp.clear();
        	ll total=0;
        	mx=0;
        	dfs(adj,col,vis,i,total);

        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)
map<ll,ll> mp;
ll mx=0;

void dfs(vector<ll> adj[],vector<ll> &col,vector<bool> &vis,ll &u,ll &total){
    vis[u]=1;
    mp[col[u]]++;
    mx=max(mx,mp[col[u]]);
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            dfs(adj,col,vis,i,total);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> col(n);
    f(i,n) cin>>col[i];

    vector<ll> adj[n];
    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    vector<bool> vis(n,0);

    ll ans=0;

    for(int i=0;i<n;i++){

        if(!vis[i]) {
            mp.clear();
        	ll total=0;
        	mx=0;
        	dfs(adj,col,vis,i,total);

        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)
map<ll,ll> mp;
ll mx=0;

void dfs(vector<ll> &adj[],vector<ll> &col,vector<bool> &vis,ll &u,ll &total){
    vis[u]=1;
    mp[col[u]]++;
    mx=max(mx,mp[col[u]]);
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            dfs(adj,col,vis,i,total);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> col(n);
    f(i,n) cin>>col[i];

    vector<ll> adj[n];
    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    vector<bool> vis(n,0);

    ll ans=0;

    for(int i=0;i<n;i++){

        if(!vis[i]) {
            mp.clear();
        	ll total=0;
        	mx=0;
        	dfs(adj,col,vis,i,total);

        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 200050;

int n, m, k, mx;
int a[MaxN], ans;
int l, r, fa[MaxN], siz[MaxN];
vector<int> G[MaxN];
map<int,int> mp;

//find
int f(int x)
{
    return fa[x] == x?x:fa[x] = f(fa[x]);
}

int main()
{

    cin>>n>>m>>k;

    rep(i,1,n) {
        cin>>a[i];
        // father
        fa[i] = i;
    }

    //connecting components
    rep(i,1,m)
    {
        cin>>l>>r;
        if(f(l) != f(r)) fa[f(l)] = f(r);
    }

    rep(i,1,n){
        //calculating size
    	siz[f(i)] ++;
    	// each father : all color
    	G[f(i)].push_back(a[i]);
    }

    rep(i,1,n){

        if(siz[i])
        {

            mp.clear(); mx = 0;

            rep(j,0,G[i].size()-1){

                mp[G[i][j]] ++;
                mx = max(mx, mp[G[i][j]]);

            }

            ans += siz[i] - mx;

        }

    }

    printf("%d",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)
map<ll,ll> mp;
ll mx=0;

void dfs(vector<ll> adj[],vector<ll> &col,vector<bool> &vis,ll u,ll &total){
    vis[u]=1;
    mp[col[u]]++;
    mx=max(mx,mp[col[u]]);
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            dfs(adj,col,vis,i,total);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> col(n);
    f(i,n) cin>>col[i];

    vector<ll> adj[n];
    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    vector<bool> vis(n,0);

    ll ans=0;

    for(int i=0;i<n;i++){

        if(!vis[i]) {
            mp.clear();
        	ll total=0;
        	mx=0;
        	dfs(adj,col,vis,i,total);

        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define f(i,n) for(int i=0;i<n;i++)
map<ll,ll> mp;
ll mx=0;

void dfs(vector<ll> adj[],vector<ll> col,vector<bool> &vis,ll u,ll &total){
    vis[u]=1;
    mp[col[u]]++;
    mx=max(mx,mp[col[u]]);
    total++;
    // cout<<u<<" ";
    for(auto i:adj[u]){
        if(!vis[i]){
            dfs(adj,col,vis,i,total);
        }
    }
}

void solve(){
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> col(n);
    f(i,n) cin>>col[i];

    vector<ll> adj[n];
    f(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        adj[a].pb(b); adj[b].pb(a);
    }

    vector<bool> vis(n,0);

    ll ans=0;

    for(int i=0;i<n;i++){

        if(!vis[i]) {
            mp.clear();
        	ll total=0;
        	mx=0;
        	dfs(adj,col,vis,i,total);

        	ans=ans+total-mx;
        }
    }
    cout<<ans;

}

int main(){
    FIO;
    int t=1;

    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()

	#define PI 3.14159265358979323846
	const int N =2e5+3;

      int mod=1e9+7;

    vi v[N];
    int sum,vis[N],col[N],cnt,maxi;

    void dfs(int u,vi &wyn){
        vis[u]=1;

        for(auto to:v[u]){
            if(!vis[to]){
              cnt++;
              wyn[col[to]]++;
              maxi=max(maxi,wyn[col[to]]);
              dfs(to,wyn);
            }
         }
     }

    void solve(){
        int n,m,k;
        cin>>n>>m>>k;

        rep(i,1,n+1){
          cin>>col[i];
        }

        rep(i,1,m+1){
            int x,y;
            cin>>x>>y;
            v[x].pb(y);
            v[y].pb(x);
        }

        rep(i,1,n+1){
               vi wyn(n+1,0);
            if(!vis[i]){
                ++wyn[col[i]];
                dfs(i,wyn);
              maxi=max(maxi,wyn[col[i]]);

               sum+=(cnt+1-maxi);
               cnt=0;
            }
            maxi=0;
        }

        cout<<sum;

    }

	int32_t main() {

	  cool;
	  int t=1;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()

	#define PI 3.14159265358979323846
	const int N =2e5+3;

      int mod=1e9+7;

       int n,m,k;
       int cnt,p[N],siz[N];

       void init(){
           rep(i,1,N){

               siz[i]=0;
           }
       }

      int findi(int x){
          return p[x];
      }

      void uni(int x,int y){
          int r1=findi(x);
          int r2=findi(y);

              if(siz[r1]>siz[r2]){
                  p[r2]=r1;
                  //~ cnt+=siz[r2];
                  siz[r1]+=siz[r2];
                  siz[r2]=0;
              }

              else{
                   p[r1]=r2;
                   //~ cnt+=siz[r1];
                  siz[r2]+=siz[r1];
                  siz[r1]=0;
              }

       }

      void solve(){
        cin>>n>>m>>k;

        init();

        //~ rep(i,1,n+1)
         //~ cout<<siz[i]<<" ";
         //~ cout<<endl;

        rep(i,1,n+1){
            int x;
            cin>>x;
            p[i]=x;
            siz[x]++;
        }

        rep(i,1,m+1){
            int x,y;
            cin>>x>>y;

           if(findi(x)==findi(y)){

              continue;
           }
           else{
              uni(x,y);
              cnt++;
           }
        }

        cout<<cnt<<endl;

      }

	int32_t main() {

	  cool;
	  int t=1;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()

	#define PI 3.14159265358979323846
	const int N =2e5+3;

      int mod=1e9+7;

    vi v[N];
    int vis[N],col[N];
    map<int,int> mp;
    int tot,maxi,sum;

    void dfs(int u){
         tot++;
         vis[u]=1;

         maxi=max(maxi,++mp[col[u]]);
        for(auto to:v[u]){
            if(!vis[to]){
                dfs(to);
         }
      }
    }

    void solve(){
        int n,m,k;
        cin>>n>>m>>k;

        rep(i,1,n+1){
          cin>>col[i];
        }

        rep(i,1,m+1){
            int x,y;
            cin>>x>>y;
            v[x].pb(y);
            v[y].pb(x);
        }

        rep(i,1,n+1){

            if(!vis[i]){
               tot=maxi=0;
               dfs(i);
               sum+=tot-maxi;
               mp.clear();
            }
        }

        cout<<sum;

    }

	int32_t main() {

	  cool;
	  int t=1;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()

	#define PI 3.14159265358979323846
	const int N =2e5+3;

      int mod=1e9+7;

       int n,m,k;
       int cnt,p[N],siz[N];

       void init(){
           rep(i,1,N){

               siz[i]=0;
           }
       }

      int findi(int x){
          return p[x];
      }

      void uni(int x,int y){
          int r1=findi(x);
          int r2=findi(y);

          if(r1!=r2){
              if(siz[r1]>siz[r2]){
                  p[r2]=r1;
                  //~ cnt+=siz[r2];
                  siz[r1]+=siz[r2];
                  siz[r2]=0;
              }

              else{
                   p[r1]=r2;
                   //~ cnt+=siz[r1];
                  siz[r2]+=siz[r1];
                  siz[r1]=0;
              }
          }

       }

      void solve(){
        cin>>n>>m>>k;

        init();

        //~ rep(i,1,n+1)
         //~ cout<<siz[i]<<" ";
         //~ cout<<endl;

        rep(i,1,n+1){
            int x;
            cin>>x;
            p[i]=x;
            siz[x]++;
        }

        rep(i,1,m+1){
            int x,y;
            cin>>x>>y;

           if(findi(x)==findi(y)){

              continue;
           }
           else{
              uni(x,y);
              cnt++;
           }
        }

        cout<<cnt<<endl;

      }

	int32_t main() {

	  cool;
	  int t=1;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()

	#define PI 3.14159265358979323846
	const int N =2e5+3;

      int mod=1e9+7;

    vi v[N];
    int sum,vis[N],col[N],cnt;

    void dfs(int u,vi &wyn){
        vis[u]=1;

        for(auto to:v[u]){
            if(!vis[to]){
              cnt++;
              wyn[col[to]]++;
              dfs(to,wyn);

            }
         }
     }

    void solve(){
        int n,m,k;
        cin>>n>>m>>k;

        rep(i,1,n+1){
          cin>>col[i];
        }

        rep(i,1,m+1){
            int x,y;
            cin>>x>>y;
            v[x].pb(y);
            v[y].pb(x);
        }

        rep(i,1,n+1){
            vi wyn(n+1,0);

            if(!vis[i]){
               wyn[col[i]]++;
                dfs(i,wyn);
               int yo=*max_element(all(wyn));
               sum+=(cnt+1-yo);
               cnt=0;
            }
        }

        cout<<sum;

    }

	int32_t main() {

	  cool;
	  int t=1;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()

	#define PI 3.14159265358979323846
	const int N =2e5+3;

      int mod=1e9+7;

       int n,m,k;
       int p[N],siz[N];

      int fin(int x){
          while(x!=p[x]){
              p[x]=p[p[x]];
              x=p[x];
          }

          return x;
      }

      void uni(int x,int y){
          int r1=fin(x);
          int r2=fin(y);

          if(r1!=r2){
              if(siz[r1]>siz[r2]){
                  p[r2]=r1;
                  siz[r1]+=siz[r2];
                  siz[r2]=0;
              }

              else{
                   p[r1]=r2;
                  siz[r2]+=siz[r1];
                  siz[r1]=0;
              }
          }
       }

      void solve(){
        cin>>n>>m>>k;

        int cnt=0;

        rep(i,1,n+1){
            int x;
            cin>>x;
            p[i]=x;
            siz[x]++;
        }

        rep(i,1,m+1){
            int x,y;
            cin>>x>>y;
           if(p[x]==p[y])
              continue;
           else{
              uni(x,y);
               cnt++;
           }
        }

        cout<<cnt<<endl;

      }

	int32_t main() {

	  cool;
	  int t=1;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()

	#define PI 3.14159265358979323846
	const int N =2e5+3;

      int mod=1e9+7;

       int n,m,k,cnt;
       int p[N],siz[N];

       void init(){
           rep(i,1,N){

               siz[i]=0;
           }
       }

      int findi(int x){
          return p[x];
      }

      void uni(int x,int y){
          int r1=findi(x);
          int r2=findi(y);

          if(r1!=r2){
              if(siz[r1]>siz[r2]){
                  p[r2]=r1;
                   cnt+=siz[r2];
                  siz[r1]+=siz[r2];
                  siz[r2]=0;
              }

              else{
                   p[r1]=r2;
                    cnt+=siz[r1];
                  siz[r2]+=siz[r1];
                  siz[r1]=0;
              }
          }

       }

      void solve(){
        cin>>n>>m>>k;

        init();

        //~ rep(i,1,n+1)
         //~ cout<<siz[i]<<" ";
         //~ cout<<endl;

        rep(i,1,n+1){
            int x;
            cin>>x;
            p[i]=x;
            siz[x]++;
        }

        rep(i,1,m+1){
            int x,y;
            cin>>x>>y;

           if(findi(x)==findi(y)){

              continue;
           }
           else{
              uni(x,y);

           }
        }

        cout<<cnt<<endl;

      }

	int32_t main() {

	  cool;
	  int t=1;

	  while (t--)
		 solve();

	  return 0;
	}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int>> vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] == index)
        return index;
    return uf[index] = Ancestor(uf[index]);
}

void Merge(int l, int r) {
    uf[Ancestor(r)] = uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        long long res = 0;

        for (int i = 1; i <= n; i++) {
            scanf("%d", &c[i]);
            uf[i] = i;
        }
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 1; i <= n; i++)
            vec[i].clear();

        for (int i = 1; i <= n; i++)
            vec[Ancestor(i)].push_back(i);

        for (int i = 1; i <= n; i++) {
            if (vec[i].size() <= 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            res += vec[i].size() - maxnum;
        }

        printf("%lld\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int> > vec(maxn);
int c[maxn];
int uf[maxn];

int Ancestor(int index) {
    if (uf[index] != index)
        return Ancestor(uf[index]);
    return index;
}

void Merge(int l, int r) {
    uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;
        for (int i = 1; i <= n; i++)
            scanf("%d", &c[i]);
        for (int i = 1; i <= n; i++)
            uf[i] = i;
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 0; i < vec.size(); i++)
            vec[i].clear();
        for (int i = 1; i <= n; i++)
            vec[uf[i]].push_back(i);
        for (int i = 1; i <= n; i++) {
            if (vec[i].size() <= 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                cout << vec[i][j] << ' ';
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            cout << endl;
            res += vec[i].size() - maxnum;
        }
        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
int c[maxn];
int uf[maxn];

int Ancestor(int index) {
    if (uf[index] != index)
        return Ancestor(uf[index]);
    return index;
}

void Merge(int l, int r) {
    uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;
        for (int i = 1; i <= n; i++)
            scanf("%d", &c[i]);
        for (int i = 1; i <= n; i++)
            uf[i] = i;
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        //for (int i = 1; i <= n; i++)
        //    cout << "i: " << i << ' ' << uf[i] << endl;

        vector<vector<int> > vec(n + 1, vector<int>(0));
        for (int i = 1; i <= n; i++)
            vec[uf[i]].push_back(i);
        for (int i = 1; i <= n; i++) {
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                //cout << vec[i][j] << ' ';
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            //cout << endl;
            res += vec[i].size() - maxnum;
        }
        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int>> vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] == index)
        return index;
    return uf[index] = Ancestor(uf[index]);
}

void Merge(int l, int r) {
    uf[Ancestor(r)] = uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;

        for (int i = 1; i <= n; i++) {
            scanf("%d", &c[i]);
            uf[i] = i;
        }
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 1; i <= n; i++)
            vec[i].clear();

        for (int i = 1; i <= n; i++)
            vec[Ancestor(uf[i])].push_back(i);

        for (int i = 1; i <= n; i++) {
            if (vec[i].size() < 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            res += vec[i].size() - maxnum;
        }

        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
int c[maxn];
int uf[maxn];

int Ancestor(int index) {
    if (uf[index] != index)
        return Ancestor(uf[index]);
    return index;
}

void Merge(int l, int r) {
    uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;
        for (int i = 1; i <= n; i++)
            scanf("%d", &c[i]);
        for (int i = 1; i <= n; i++)
            uf[i] = i;
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        //for (int i = 1; i <= n; i++)
            //cout << "i: " << i << ' ' << uf[i] << endl;

        vector<vector<int> > vec(max(n, k) + 5, vector<int>(0));
        for (int i = 1; i <= n; i++)
            vec[uf[i]].push_back(i);
        for (int i = 1; i <= n; i++) {
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                //cout << vec[i][j] << ' ';
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            //cout << endl;
            res += vec[i].size() - maxnum;
        }
        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int> > vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] != index)
        return Ancestor(uf[index]);
    return index;
}

void Merge(int l, int r) {
    uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;
        for (int i = 1; i <= n; i++)
            scanf("%d", &c[i]);
        for (int i = 1; i <= n; i++)
            uf[i] = i;
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 0; i < vec.size(); i++)
            vec[i].clear();
        for (int i = 1; i <= n; i++)
            vec[Ancestor(i)].push_back(i);
        for (int i = 1; i <= n; i++) {
            if (vec[i].size() <= 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                //cout << vec[i][j] << ' ';
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            //cout << endl;
            res += vec[i].size() - maxnum;
        }
        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int>> vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] == index)
        return index;
    return uf[index] = Ancestor(uf[index]);
}

void Merge(int l, int r) {
    uf[Ancestor(r)] = uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        long long res = 0;

        for (int i = 1; i <= n; i++) {
            scanf("%d", &c[i]);
            uf[i] = i;
        }
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 1; i <= n; i++)
            vec[i].clear();

        for (int i = 1; i <= n; i++)
            vec[Ancestor(uf[i])].push_back(i);

        for (int i = 1; i <= n; i++) {
            if (vec[i].size() < 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            res += vec[i].size() - maxnum;
        }

        printf("%lld\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
int c[maxn];
int uf[maxn];

int Ancestor(int index) {
    if (uf[index] != index)
        return Ancestor(uf[index]);
    return index;
}

void Merge(int l, int r) {
    uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;
        for (int i = 1; i <= n; i++)
            scanf("%d", &c[i]);
        for (int i = 1; i <= k; i++)
            uf[i] = i;
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        vector<vector<int> > vec(k + 1, vector<int>(0));
        for (int i = 1; i <= k; i++)
            vec[uf[i]].push_back(i);
        for (int i = 1; i <= k; i++) {
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            res += vec[i].size() - maxnum;
        }
        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int> > vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] != index)
        return Ancestor(uf[index]);
    return index;
}

void Merge(int l, int r) {
    uf[Ancestor(r)] = uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;
        for (int i = 1; i <= n; i++)
            scanf("%d", &c[i]);
        for (int i = 1; i <= n; i++)
            uf[i] = i;
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 0; i < vec.size(); i++)
            vec[i].clear();
        for (int i = 1; i <= n; i++)
            vec[Ancestor(i)].push_back(i);
        for (int i = 1; i <= n; i++) {
            if (vec[i].size() <= 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                //cout << vec[i][j] << ' ';
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            //cout << endl;
            res += vec[i].size() - maxnum;
        }
        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int>> vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] == index)
        return index;
    return uf[index] = Ancestor(uf[index]);
}

void Merge(int l, int r) {
    uf[Ancestor(r)] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        long long res = 0;

        for (int i = 1; i <= n; i++) {
            scanf("%d", &c[i]);
            uf[i] = i;
        }
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 1; i <= n; i++)
            vec[i].clear();

        for (int i = 1; i <= n; i++)
            vec[Ancestor(i)].push_back(i);

        for (int i = 1; i <= n; i++) {
            if (vec[i].size() <= 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            res += vec[i].size() - maxnum;
        }

        printf("%lld\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int>> vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] == index)
        return index;
    return Ancestor(uf[index]);
}

void Merge(int l, int r) {
    uf[Ancestor(r)] = uf[r] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        int res = 0;

        for (int i = 1; i <= n; i++)
            uf[i] = i;
        for (int i = 1; i <= n; i++)
            scanf("%d", &c[i]);
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 1; i <= n; i++)
            vec[i].clear();

        for (int i = 1; i <= n; i++)
            vec[Ancestor(uf[i])].push_back(i);

        for (int i = 1; i <= n; i++) {
            if (vec[i].size() < 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[c[vec[i][j]]]++;
                if (mp[c[vec[i][j]]] > maxnum)
                    maxnum = mp[c[vec[i][j]]];
            }
            res += vec[i].size() - maxnum;
        }

        printf("%d\n", res);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

const int maxn = 2e5 + 10;
vector<vector<int>> vec(maxn);
int uf[maxn];
int c[maxn];

int Ancestor(int index) {
    if (uf[index] == index)
        return index;
    return uf[index] = Ancestor(uf[index]);
}

void Merge(int l, int r) {
    uf[Ancestor(r)] = Ancestor(l);
}

int main() {
    int n, m, k;
    while (~scanf("%d%d%d", &n, &m, &k)) {
        long long res = 0;

        for (int i = 1; i <= n; i++) {
            scanf("%d", &c[i]);
            uf[i] = i;
        }
        for (int i = 0; i < m; i++) {
            int l, r;
            scanf("%d%d", &l, &r);
            Merge(l, r);
        }

        for (int i = 1; i <= n; i++)
            vec[i].clear();

        for (int i = 1; i <= n; i++)
            vec[Ancestor(i)].push_back(c[i]);

        for (int i = 1; i <= n; i++) {
            if (vec[i].size() <= 1)
                continue;
            map<int, int> mp;
            int maxnum = 0;
            for (int j = 0; j < vec[i].size(); j++) {
                mp[vec[i][j]]++;
                if (mp[vec[i][j]] > maxnum)
                    maxnum = mp[vec[i][j]];
            }
            res += vec[i].size() - maxnum;
        }

        printf("%lld\n", res);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int N=200005;
int n,m,k;
int col[N],f[N];
vector<int> G[N];
int gt(int x){
	if(f[x]!=x) f[x]=gt(f[x]);
	return f[x];
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
	}
	for(int i=1;i<=n;i++) f[i]=i,G[i].clear();
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r);
		f[gt(l)]=gt(r);
	}
	for(int i=1;i<=n;i++){
		G[gt(i)].push_back(col[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(G[i].size()>1){
			sort(G[i].begin(),G[i].end());
			int k=0,sum,ma=1;
			while(k+1<G[i].size()){
				sum=1;
				while(G[i][k]==G[i][k+1] and k+1<G[i].size()){
					k++;
					sum++;
				}
				if(G[i][k]==G[i][k+1]) sum++;
				if(sum>ma) ma=sum;
				k++;
			}
			ans+=G[i].size()-ma;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int N=200005;
int n,m,k;
int col[N],f[N],cnt[N];
vector<int> G[N];
int gt(int x){
	if(f[x]!=x) f[x]=gt(f[x]);
	return f[x];
}
int max1(int x,int y){
	return x>y?x:y;
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
	}
	for(int i=1;i<=n;i++) f[i]=i,G[i].clear();
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r);
		f[gt(l)]=gt(r);
	}
	for(int i=1;i<=n;i++){
		G[gt(i)].push_back(col[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(G[i].size()>1){
			for(int j=1;j<=k;j++) cnt[j]=0;
			int ma=0;
			for(int j=0;j<G[i].size();j++){
				cnt[G[i][j]]++;
				ma=max1(cnt[G[i][j]],ma);
			}
			ans+=G[i].size()-ma;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
int n,m,k;
int col[N],f[N];
struct node{
	int c,f;
}data[N];
int gt(int x){
	if(f[x]!=x) f[x]=gt(f[x]);
	return f[x];
}
bool cmp(node a,node b){
	if(a.f==b.f) return a.c<b.c;
	return a.f<b.f;
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
	}
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r);
		f[gt(l)]=gt(r);
	}
	for(int i=1;i<=n;i++){
		data[i].c=col[i];
		data[i].f=gt(i);
	}
	sort(data+1,data+n+1,cmp);
	int sum=1,ma=1,ans=n;
	for(int i=1;i<=n;i++){
		if(data[i].f==data[i+1].f and data[i].c==data[i+1].c){
			sum++;
		}else{
			if(sum>ma) ma=sum;
			if(data[i].f!=data[i+1].f){
				ans-=ma;
				ma=1;
			}
			sum=1;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N=200005;
int n,m,k;
int col[N];
int f[N],c[N];
vector<int>v[N];
int gt(int x){
	if(f[x]!=x) f[x]=gt(f[x]);
	return f[x];
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%d",&col[i]);
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r);
		f[gt(l)]=gt(r);
	}
	//ͳ��
	for(int i=1;i<=n;i++){
		v[gt(i)].push_back(col[i]);
	}
	int ans=n;
	for(int i=1;i<=n;i++){
		if(!v[i].size()) continue;
		sort(v[i].begin(),v[i].end());
		int ma=0,num=0;
//		printf("%d ",v[i][0]);
		for(int j=1;j<v[i].size();j++){
//			printf("%d ",v[i][j]);
			num++;
			if(v[i][j]!=v[i][j-1]){
				if(num>ma) ma=num;
				num=0;
			}
		}
		num++;
		if(num>ma) ma=num;
		ans-=ma;
//		puts("");
	}
	printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int N=200005;
int n,m,k;
int col[N],f[N];
vector<int> G[N];
int gt(int x){
	if(f[x]!=x) f[x]=gt(f[x]);
	return f[x];
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&col[i]);
	}
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r);
		f[gt(l)]=gt(r);
	}
	for(int i=1;i<=n;i++){
		G[gt(i)].push_back(col[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(G[i].size()>1){
			sort(G[i].begin(),G[i].end());
			int k=0,sum,ma=1;
			while(k<G[i].size()){
				sum=1;
				while(G[i][k]==G[i][k+1] and k<G[i].size()){
					k++;
					sum++;
				}
				if(sum>ma) ma=sum;
				k++;
			}
			ans+=G[i].size()-ma;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=200009;

int n,m,k,ans,c[N],r1[N],l1[N],f[N],max1,num;
vector<int>v[N];
int gt(int x) {
	if(f[x]!=x) f[x]=gt(f[x]);
	return f[x];
}

int main() {
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&c[i]);
		f[i]=i;
	}
	for(int i=1;i<=m;++i){
		scanf("%d%d",&l1[i],&r1[i]);
		f[gt(l1[i])]=gt(r1[i]);
	}

	for(int i=1;i<=n;++i)
		v[gt(i)].push_back(c[i]);
	ans=n;
	for(int i=1;i<=n;++i){
		if(!v[i].size()) continue;
		sort(v[i].begin(),v[i].end());
		max1=0;num=0;
		for(int j=1;j<v[i].size();++j){
			num++;
			if(v[i][j]!=v[i][j-1]){
				if(num>max1) max1=num;
				num=0;

			}
		}
		num++;
		if(num>max1) max1=num;
		ans=ans-max1;
	}
	printf("%d",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=200009;

int n,m,k,ans,c[N],r1[N],l1[N],f[N],max1,num;
vector<int>v[N];
int gt(int x) {
	if(f[x]!=x) f[x]=gt(f[x]);
	return f[x];
}

int main() {
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&c[i]);
		f[i]=i;
	}
	for(int i=1;i<=m;++i){
		scanf("%d%d",&l1[i],&r1[i]);
		f[gt(l1[i])]=gt(r1[i]);
	}

	for(int i=1;i<=n;++i)
		v[gt(i)].push_back(c[i]);
	ans=n;
	for(int i=1;i<=n;++i){
//		if(!v[i].size()) continue;
		sort(v[i].begin(),v[i].end());
		max1=0;num=0;
		for(int j=1;j<=v[i].size();++j){
			num++;
			if(v[i][j]!=v[i][j-1]){
				if(num>max1) max1=num;
				num=0;

			}
		}
		ans=ans-max1;
	}
	printf("%d",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int BFS(int V, vector<int>* adj, vector<int>& socks,vector<bool>& visited){
    unordered_map<int,int> cfreq;
    vector<int>::iterator i;
    queue<int> que;
    que.push(V);
    int n = 0;
    while(!que.empty()){
        int V = que.front(); que.pop();
        visited[V] = true;
        n++;
        cfreq[socks[V]]++;
        for(i = adj[V].begin(); i!= adj[V].end(); ++i)
            if(!visited[*i])
                que.push(*i);
    }
    int m = 0;
    for(auto i:cfreq){
        m = max(m,i.second);
    }
    return n-m;
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> socks(n+1,0);
    for(int i = 1; i<=n; ++i)
        cin>>socks[i];
    int l,r;
    vector<int>* adj = new vector<int>[n+1];
    for(int i = 0; i<m; ++i){
        cin>>l>>r;
        adj[l].push_back(r);
        adj[r].push_back(l);
    }
    vector<bool> visited(n+1,false);
    ll ans = 0;
    for(int i = 1; i<=n; ++i){
        if(!visited[i] && adj[i].size()>0){
            ans += BFS(i,adj,socks,visited);
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int BFS(int V, vector<int>* adj, vector<int>& socks,vector<bool>& visited){
    unordered_map<int,int> cfreq;
    vector<int>::iterator i;
    queue<int> que;
    que.push(V);
    int n = 0;
    while(!que.empty()){
        int V = que.front(); que.pop();
        visited[V] = true;
        n++;
        cfreq[socks[V]]++;
        for(i = adj[V].begin(); i!= adj[V].end(); ++i)
            if(!visited[*i])
                que.push(*i);
    }
    int m = 0;
    for(auto i:cfreq){
        m = max(m,i.second);
    }
    return n-m;
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> socks(n+1,0);
    for(int i = 1; i<=n; ++i)
        cin>>socks[i];
    int l,r;
    vector<int>* adj = new vector<int>[n+1];
    vector<int> v;
    for(int i = 0; i<m; ++i){
        cin>>l>>r;
        adj[l].push_back(r);
        adj[r].push_back(l);
        v.push_back(l); v.push_back(r);
    }
    vector<bool> visited(n+1,false);
    ll ans = 0;
    for(int i:v){
        if(!visited[i]){
            ans += BFS(i,adj,socks,visited);
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int BFS(int V, vector<int>* adj, vector<int>& socks,vector<bool>& visited){
    unordered_map<int,int> cfreq;
    vector<int>::iterator i;
    queue<int> que;
    que.push(V);
    int n = 0;
    while(!que.empty()){
        int V = que.front(); que.pop();
        visited[V] = true;
        n++;
        cfreq[socks[V]]++;
        for(i = adj[V].begin(); i!= adj[V].end(); ++i)
            if(!visited[*i])
                que.push(*i);
    }
    int m = 0;
    for(auto i:cfreq){
        m = max(m,i.second);
    }
    return n-m;
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> socks(n+1,0);
    for(int i = 1; i<=n; ++i)
        cin>>socks[i];
    int l,r;
    vector<int>* adj = new vector<int>[n+1];
    for(int i = 0; i<m; ++i){
        cin>>l>>r;
        adj[l].push_back(r);
        adj[r].push_back(l);
    }
    vector<bool> visited(n+1,false);
    ll ans = 0;
    for(int i = 1; i<=n; ++i){
        if(!visited[i]){
            ans += BFS(i,adj,socks,visited);
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int BFS(int V, vector<int>* adj, vector<int>& socks,vector<bool>& visited){
    unordered_map<int,int> cfreq;
    vector<int>::iterator i;
    queue<int> que;
    que.push(V);
    visited[V] = true;
    int n = 0;
    while(!que.empty()){
        int V = que.front(); que.pop();

        n++;
        cfreq[socks[V]]++;
        for(i = adj[V].begin(); i!= adj[V].end(); ++i)
            if(!visited[*i])
                que.push(*i),visited[*i] = true;
    }
    int m = 0;
    for(auto i:cfreq){
        m = max(m,i.second);
    }
    return n-m;
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> socks(n+1,0);
    for(int i = 1; i<=n; ++i)
        cin>>socks[i];
    int l,r;
    vector<int>* adj = new vector<int>[n+1];
    for(int i = 0; i<m; ++i){
        cin>>l>>r;
        adj[l].push_back(r);
        adj[r].push_back(l);
    }
    vector<bool> visited(n+1,false);
    ll ans = 0;
    for(int i = 1; i<=n; ++i){
        if(!visited[i] && adj[i].size()>0){
            ans += BFS(i,adj,socks,visited);
        }
    }
    cout<<ans;
}


#include <iostream>
#include <vector>
using namespace std;

const int mxN = 2e5 + 5;
int par[mxN], Size[mxN], color[mxN], freq[mxN];
vector <int> graph[mxN];

int find_set(int x) {
	return par[x] = x == par[x] ? x : find_set(par[x]);
}

void union_set(int x, int y) {
	x = find_set(x);
	y = find_set(y);
	if(x != y) {
		if(Size[x] < Size[y])
			swap(x, y);
		Size[x] += Size[y];
		par[y] = x;
	}
}

int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", color + i);
		par[i] = i;
		Size[i] = 1;
	}
	while(m--) {
		int u, v;
		scanf("%d%d", &u, &v);
		union_set(u, v);
	}
	for(int i = 1; i <= n; ++i) {
		int cur = find_set(i);
		graph[cur].push_back(i);
	}
	int answer = 0;
	for(int i = 4; i <= n; ++i) {
		int cur_max = 0;
		int S = graph[i].size();
		if(S == 1)
			continue;
		vector <int> v;
		for(int &x : graph[i]) {
			++freq[color[x]];
			cur_max = max(cur_max, freq[color[x]]);
			v.push_back(color[x]);
		}
		for(int &x : v)
			freq[x] = 0;
		answer += S - cur_max;
	}
	printf("%d", answer);
}


#include <iostream>
#include <vector>
using namespace std;

const int mxN = 2e5 + 5;
int par[mxN], Size[mxN], color[mxN], freq[mxN];
vector <int> graph[mxN];

int find_set(int x) {
	return par[x] = x == par[x] ? x : find_set(par[x]);
}

void union_set(int x, int y) {
	x = find_set(x);
	y = find_set(y);
	if(x != y) {
		if(Size[x] < Size[y])
			swap(x, y);
		Size[x] += Size[y];
		par[y] = x;
	}
}

int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", color + i);
		par[i] = i;
		Size[i] = 1;
	}
	while(m--) {
		int u, v;
		scanf("%d%d", &u, &v);
		union_set(u, v);
	}
	for(int i = 1; i <= n; ++i) {
		int cur = find_set(i);
		graph[cur].push_back(i);
	}
	int answer = 0;
	for(int i = 1; i <= n; ++i) {
		int cur_max = 0;
		int S = graph[i].size();
		for(int &x : graph[i]) {
			++freq[color[x]];
			cur_max = max(cur_max, freq[color[x]]);
		}
		answer += S - cur_max;
	}
	printf("%d", answer);
}


#include <iostream>
#include <vector>
using namespace std;

const int mxN = 2e5 + 5;
int color[mxN], freq[mxN];

int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= n; ++i)
		scanf("%d", color + i);
	vector <pair<int, int>> vp;
	for(int i = 0; i < m; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		vp.push_back(make_pair(l, r));
		++freq[color[l]];
		++freq[color[r]];
	}
	int answer = 0;
	for(int i = 0; i < m; ++i) {
		pair <int, int> cur = vp[i];
		if(color[cur.first] == color[cur.second])
			continue;
		answer += min(freq[color[cur.first]], freq[color[cur.second]]);
		if(freq[color[cur.first]] > freq[color[cur.second]]) {
			freq[color[cur.first]] += freq[color[cur.second]];
			freq[color[cur.second]] = 0;
			color[cur.second] = color[cur.first];
		}
		else {
			freq[color[cur.second]] += freq[color[cur.first]];
			freq[color[cur.first]] = 0;
			color[cur.first] = color[cur.second];
		}
	}
	printf("%d", answer);
}


#include <iostream>
#include <vector>
using namespace std;

const int mxN = 2e5 + 5;
int par[mxN], Size[mxN], color[mxN], freq[mxN];
vector <int> graph[mxN];

int find_set(int x) {
	return par[x] = x == par[x] ? x : find_set(par[x]);
}

void union_set(int x, int y) {
	x = find_set(x);
	y = find_set(y);
	if(x != y) {
		if(Size[x] < Size[y])
			swap(x, y);
		Size[x] += Size[y];
		par[y] = x;
	}
}

int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", color + i);
		par[i] = i;
		Size[i] = 1;
	}
	while(m--) {
		int u, v;
		scanf("%d%d", &u, &v);
		union_set(u, v);
	}
	for(int i = 1; i <= n; ++i) {
		int cur = find_set(i);
		graph[cur].push_back(i);
	}
	int answer = 0;
	for(int i = 1; i <= n; ++i) {
		int cur_max = 0;
		int S = graph[i].size();
		vector <int> v;
		for(int &x : graph[i]) {
			++freq[color[x]];
			cur_max = max(cur_max, freq[color[x]]);
			v.push_back(color[x]);
		}
		for(int &x : v)
			freq[x] = 0;
		answer += S - cur_max;
	}
	printf("%d", answer);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn];
vector<int> g[maxn];

int f(int u)
{
	freq[colors[u]] ++;
	vis[u] = 1;
	int s = 1;
	for(auto v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}

	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k, maxColor = 0;
	scanf("%d%d%d",&n,&m,&k);

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		maxColor = max(maxColor, colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		memset(freq, 0 , sizeof freq);
		if(vis[i]) continue;
		int s = f(i), m = 0;

		for(int j = 0; j <= maxColor; j++)
			m = max(m , freq[j]);

		ans += (s - m);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , maxi;
vector<int> g[maxn];

int f(int u)
{
	++freq[colors[u]];
	maxi = max(maxi, freq[colors[u]]);
	vis[u] = 1;
	int s = 1;

	for(auto & v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}

	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);

	vector<int> cc;

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		cc.push_back(colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		if(vis[i]) continue;
		memset(freq, 0 , sizeof freq);
		maxi = 0;
		int s = f(i);
		ans += (s - maxi);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , qtd_most_frequent_color;
vector<int> g[maxn];

stack<int> cu;

int f(int u)
{
	qtd_most_frequent_color = max(qtd_most_frequent_color, ++freq[colors[u]]);

	if(freq[colors[u]] == 1)
		cu.push(colors[u]);

	int s = vis[u] = 1;

	for(auto & v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}
	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);

	for(int i = 0 ; i < n ; i++)
		scanf("%d",&colors[i]);

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0, sum;

	for(int i = 0 ; i < n ; i++)
	{
		if(vis[i]) continue;
		while(!cu.empty())
		{
			freq[cu.top()] = 0;
			cu.pop();
		}

		qtd_most_frequent_color = 0;
		sum = f(i);
		ans += (sum - qtd_most_frequent_color);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , maxi;
vector<int> g[maxn];

int f(int u)
{
	++freq[colors[u]];
	maxi = max(maxi, freq[colors[u]]);
	vis[u] = 1;
	int s = 1;
	for(auto v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}

	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k, maxColor = 0;
	scanf("%d%d%d",&n,&m,&k);

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		maxColor = max(maxColor, colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		memset(freq, 0 , sizeof freq);
		if(vis[i]) continue;
		maxi = 0;
		int s = f(i);

		ans += (s - maxi);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , maxi;
vector<int> g[maxn];

int f(int u)
{
	++freq[colors[u]];
	maxi = max(maxi, freq[colors[u]]);
	vis[u] = 1;
	int s = 1;
	for(auto v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}

	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k, maxColor = 0;
	scanf("%d%d%d",&n,&m,&k);

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		maxColor = max(maxColor, colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		if(vis[i]) continue;
		memset(freq, 0 , sizeof freq);
		maxi = 0;
		int s = f(i);

		ans += (s - maxi);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , maxi;
vector<int> g[maxn];

int f(int u)
{
	++freq[colors[u]];
	maxi = max(maxi, freq[colors[u]]);
	vis[u] = 1;
	int s = 1;
	for(auto v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}
	//
	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);

	vector<int> cc;

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		cc.push_back(colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		if(vis[i]) continue;

		for(auto q : cc)
			freq[q] = 0;

		maxi = 0;
		int s = f(i);
		ans += (s - maxi);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , maxi;
vector<int> g[maxn];

int f(int u)
{
	++freq[colors[u]];
	maxi = max(maxi, freq[colors[u]]);
	vis[u] = 1;
	int s = 1;

	for(auto & v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}

	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);

	vector<int> cc;

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		cc.push_back(colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		if(vis[i]) continue;
		for(auto & q : cc)
			freq[q] = 0;
		maxi = 0;
		int s = f(i);
		ans += (s - maxi);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , maxi;
vector<int> g[maxn];

int f(int u)
{
	++freq[colors[u]];
	maxi = max(maxi, freq[colors[u]]);
	vis[u] = 1;
	int s = 1;
	for(auto v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}

	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);

	vector<int> cc;

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		cc.push_back(colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		if(vis[i]) continue;
		memset(freq, 0 , sizeof freq);
		maxi = 0;
		int s = f(i);
		ans += (s - maxi);
	}

	printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;

#define maxn 200009

int colors[maxn], vis[maxn], freq[maxn] , maxi;
vector<int> g[maxn];

int f(int u)
{
	++freq[colors[u]];
	maxi = max(maxi, freq[colors[u]]);
	vis[u] = 1;
	int s = 1;
	for(auto v : g[u])
	{
		if(vis[v]) continue;
		s += f(v);
	}

	return s;
}

int main()
{

	//~ freopen("in", "r", stdin);

	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);

	vector<int> cc;

	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d",&colors[i]);
		cc.push_back(colors[i]);
	}

	while(m--)
	{
		int a, b;
		scanf("%d%d",&a,&b);
		a--;b--;

		g[a].push_back(b);
		g[b].push_back(a);

	}

	int ans = 0;

	for(int i = 0 ; i < n ; i++)
	{
		if(vis[i]) continue;

		for(auto q : cc)
			freq[q] = 0;

		maxi = 0;
		int s = f(i);
		ans += (s - maxi);
	}

	printf("%d\n",ans);
}


//https://www.hackerrank.com/challenges/equal/problem
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
const int MAX = 2e5+10;
int n,m,k;
vector<int> p[MAX];
int color[MAX], par[MAX], sz[MAX], vis[MAX];
vector<int> cl(MAX);
int find(int x){
    return (par[x] == x)? x: (par[x] = find(par[x]));
}
void merge(int u, int v){
    u = find(u);
    v = find(v);
    if(u == v) return;
    else{
        par[v] = u;
        sz[u] += sz[v];
    }
}
void DFS(int x){
    cl[color[x]]++;
    vis[x] = 1;
    for(auto y: p[x]){
        if(vis[y]==0){
            DFS(y);
        }
    }
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int u,v;
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++){
        cin>>color[i];
        par[i] = i;
        sz[i] = 1;
    }
    for(int i=1; i<=m; i++){
        cin>>u>>v;
        p[u].push_back(v);
        p[v].push_back(u);
        merge(u, v);
    }
    int res = 0, tmp ;
    for(int i=1; i<=n; i++){
        if(par[i] == i && sz[i] > 1){
            tmp = 0;
            for(int j=1; j<=k; j++) cl[j] = 0;
            DFS(i);
            for(int j = 1; j<=k; j++) tmp = max(tmp, cl[j]);
            //cout<<"tmp: "<<tmp<<' '<<"sz: "<<sz[i]<<endl;
            res += sz[i] - tmp;
        }
    }
    cout<<res;

}


//https://www.hackerrank.com/challenges/equal/problem
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
const int MAX = 2e5+10;
int n,m,k;
vector<int> p[MAX];
int color[MAX], par[MAX], sz[MAX], vis[MAX];
int find(int x){
    return (par[x] == x)? x: (par[x] = find(par[x]));
}
void merge(int u, int v){
    u = find(u);
    v = find(v);
    if(u == v) return;
    else{
        par[v] = u;
        sz[u] += sz[v];
    }
}
int tmp = 0;
void DFS(int x, vector<int> &cl){
    cl[color[x]]++;
    tmp = max(tmp, cl[color[x]]);
    vis[x] = 1;
    for(auto y: p[x]){
        if(vis[y] == 0) DFS(y, cl);
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int u, v;
    cin >> n >> m >> k;
    for(int i=1; i<=n; i++){
        cin>>color[i];
        par[i] = i;
        sz[i] = 1;
    }
    for(int i=1; i<=m; i++){
        cin>>u>>v;
        p[u].push_back(v);
        p[v].push_back(u);
        merge(u, v);
    }int res = 0;
    for(int i=1; i<=n; i++){
        if(par[i] == i && sz[i] > 1){
            tmp = 0;
            vector<int> cl(k+1, 0);
            DFS(i, cl);
            res += sz[i] - tmp;
        }
    }
    cout<<res;
}


//https://www.hackerrank.com/challenges/equal/problem
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
const int MAX = 2e5+10;
int n,m,k;
vector<int> p[MAX];
int color[MAX], vis[MAX];
int tmp = 0, cnt = 0;
void DFS(int x, vector<int> &cl){
    cl[color[x]]++;
    cnt++;
    tmp = max(tmp, cl[color[x]]);
    vis[x] = 1;
    for(auto y: p[x]){
        if(vis[y] == 0) DFS(y, cl);
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int u, v;
    cin >> n >> m >> k;
    for(int i=1; i<=n; i++){
        cin>>color[i];
    }
    for(int i=1; i<=m; i++){
        cin>>u>>v;
        p[u].push_back(v);
        p[v].push_back(u);
    }int res = 0;
    for(int i=1; i<=n; i++){
        if(vis[i] == 0){
            cnt = tmp = 0;
            vector<int> cl(k+1, 0);
            DFS(i, cl);
            res += cnt - tmp;
        }
    }
    cout<<res;
}


//https://www.hackerrank.com/challenges/equal/problem
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
const int MAX = 2e5+10;
int n,m,k;
vector<int> p[MAX];
int color[MAX], vis[MAX];
map<int, int> cl;
int tmp = 0, cnt = 0;
void DFS(int x){
    cl[color[x]]++;
    cnt++;
    tmp = max(tmp, cl[color[x]]);
    vis[x] = 1;
    for(auto y: p[x]){
        if(vis[y] == 0) DFS(y);
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int u, v;
    cin >> n >> m >> k;
    for(int i=1; i<=n; i++){
        cin>>color[i];
    }
    for(int i=1; i<=m; i++){
        cin>>u>>v;
        p[u].push_back(v);
        p[v].push_back(u);
    }int res = 0;
    for(int i=1; i<=n; i++){
        if(vis[i] == 0){
            cnt = tmp = 0;
            cl.clear();
            DFS(i);
            res += cnt - tmp;
        }
    }
    cout<<res;
}


//https://www.hackerrank.com/challenges/equal/problem
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
const int MAX = 2e5+10;
int n,m,k;
vector<int> p[MAX];
int color[MAX], par[MAX], sz[MAX], vis[MAX];
int find(int x){
    return (par[x] == x)? x: (par[x] = find(par[x]));
}
void merge(int u, int v){
    u = find(u);
    v = find(v);
    if(u == v) return;
    else{
        par[v] = u;
        sz[u] += sz[v];
    }
}
void DFS(int x, vector<int> &cl){
    cl[color[x]]++;
    vis[x] = 1;
    for(auto y: p[x]){
        if(vis[y]==0){
            DFS(y, cl);
        }
    }
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int u,v;
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++){
        cin>>color[i];
        par[i] = i;
        sz[i] = 1;
    }
    for(int i=1; i<=m; i++){
        cin>>u>>v;
        p[u].push_back(v);
        p[v].push_back(u);
        merge(u, v);
    }
    int res = 0, tmp ;
    for(int i=1; i<=n; i++){
        if(par[i] == i && sz[i] > 1){
            tmp = 0;
            vector<int> cl(k+1, 0);
            DFS(i, cl);
            for(int j = 1; j<=k; j++) tmp = max(tmp, cl[j]);
            //cout<<"tmp: "<<tmp<<' '<<"sz: "<<sz[i]<<endl;
            res += sz[i] - tmp;
        }
    }
    cout<<res;

}


/*
         --┬--  |     |  --┬--                |       |
           |    |\    |    |                  |       |
           |    | \   |    |     ----->       |       |
           |    |  \  |    |                  |       |
           |    |   \ |    |                  |       |
         --┴--  |    \|    |                  └----   └----

*/

#define pragma

#ifdef pragma
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC diagnostic ignored "-Wunused-result"
#endif // pragma

#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define all(x) begin(x), end(x)
#define pb push_back
#define x first
#define y second
//#define int long long
#define zero(x) memset(x, 0, sizeof(x))

using namespace std;
using namespace __gnu_pbds;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<vi> matrix;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const ld EPS = 1e-6;
const ld PI = atan2(0, -1);

void seriy() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//     cout << fixed << setprecision(15);
    #if _android
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif
}

template <class T = int> inline T readInt();
inline double readDouble();
inline int readUInt();
inline int readChar(); // first non-blank character
inline void readWord( char *s );
inline bool readLine( char *s ); // do not save '\n'
inline bool isEof();
inline int getChar();
inline int peekChar();
inline bool seekEof();
inline void skipBlanks();

template <class T> inline void writeInt( T x, char end = 0, int len = -1 );
inline void writeChar( int x );
inline void writeWord( const char *s );
inline void writeDouble( double x, int len = 0 );
inline void flush();

static struct buffer_flusher_t {
    ~buffer_flusher_t() {
        flush();
    }
} buffer_flusher;

/** Read */

static const int buf_size = 4096;

static unsigned char buf[buf_size];
static int buf_len = 0, buf_pos = 0;

inline bool isEof() {
    if (buf_pos == buf_len) {
        buf_pos = 0, buf_len = fread(buf, 1, buf_size, stdin);
        if (buf_pos == buf_len)
            return 1;
    }
    return 0;
}

inline int getChar() {
    return isEof() ? -1 : buf[buf_pos++];
}

inline int peekChar() {
    return isEof() ? -1 : buf[buf_pos];
}

inline bool seekEof() {
    int c;
    while ((c = peekChar()) != -1 && c <= 32)
        buf_pos++;
    return c == -1;
}

inline void skipBlanks() {
    while (!isEof() && buf[buf_pos] <= 32U)
        buf_pos++;
}

inline int readChar() {
    int c = getChar();
    while (c != -1 && c <= 32)
        c = getChar();
    return c;
}

inline int readUInt() {
    int c = readChar(), x = 0;
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return x;
}

template <class T>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    else if (c == '+')
        c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}

inline double readDouble() {
    int s = 1, c = readChar();
    double x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    if (c == '.') {
        c = getChar();
        double coef = 1;
        while ('0' <= c && c <= '9')
            x += (c - '0') * (coef *= 1e-1), c = getChar();
    }
    return s == 1 ? x : -x;
}

inline void readWord( char *s ) {
    int c = readChar();
    while (c > 32)
        *s++ = c, c = getChar();
    *s = 0;
}

inline bool readLine( char *s ) {
    int c = getChar();
    while (c != '\n' && c != -1)
        *s++ = c, c = getChar();
    *s = 0;
    return c != -1;
}

/** Write */

static int write_buf_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
    if (write_buf_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_buf_pos = 0;
    write_buf[write_buf_pos++] = x;
}

inline void flush() {
    if (write_buf_pos)
        fwrite(write_buf, 1, write_buf_pos, stdout), write_buf_pos = 0;
}

template <class T>
inline void writeInt( T x, char end, int output_len ) {
    if (x < 0)
        writeChar('-'), x = -x;

    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n < output_len)
        s[n++] = '0';
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}

inline void writeWord( const char *s ) {
    while (*s)
        writeChar(*s++);
}

inline void writeDouble( double x, int output_len ) {
    if (x < 0)
        writeChar('-'), x = -x;
    int t = (int)x;
    writeInt(t), x -= t;
    writeChar('.');
    for (int i = output_len - 1; i > 0; i--) {
        x *= 10;
        t = std::min(9, (int)x);
        writeChar('0' + t), x -= t;
    }
    x *= 10;
    t = std::min(9, (int)(x + 0.5));
    writeChar('0' + t);
}

matrix g;
vb used;
vi cnt, c, last;
int mx = -INF, ans = 0, sum = 0;

void dfs(int u, int i) {
    used[u] = 1;
    if(last[c[u]] != i) cnt[c[u]] = 0;
    cnt[c[u]]++;
    last[c[u]] = i;
    mx = max(mx, cnt[c[u]]);
    sum++;
    for(auto v : g[u]) {
        if(!used[v]) {
            dfs(v, i);
        }
    }
}

signed main() {
    seriy();
    int n, m, k;
    n = readInt();
    m = readInt();
    k = readInt();
//    cerr << m;
    cnt.resize(k + 1);
//    readChar();
    g.resize(n);
    used.resize(n);
    last.resize(k + 1);
    c.resize(n);
    for(int i = 0; i < n; i++) {
        c[i] = readInt();
//        cerr << c[i];
    }
    int st;
    for(int i = 0; i < m; i++) {
        int u, v;
        u = readInt();
//        readChar();
        v = readInt();
        u--;
        v--;
        st = u;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(int i = 0; i < n; i++) {
        if(!used[i]) {
//            cnt.assign(k + 1, 0);
            sum = 0;
            mx = -INF;
            dfs(i, i);
            ans += sum - mx;
        }
    }
    cout << ans;
    return 0;
}


/*
         --┬--  |     |  --┬--                |       |
           |    |\    |    |                  |       |
           |    | \   |    |     ----->       |       |
           |    |  \  |    |                  |       |
           |    |   \ |    |                  |       |
         --┴--  |    \|    |                  └----   └----

*/

#define pragma

#ifdef pragma
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC diagnostic ignored "-Wunused-result"
#endif // pragma

#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define all(x) begin(x), end(x)
#define pb push_back
#define x first
#define y second
//#define int long long
#define zero(x) memset(x, 0, sizeof(x))

using namespace std;
using namespace __gnu_pbds;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<vi> matrix;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const ld EPS = 1e-6;
const ld PI = atan2(0, -1);

void seriy() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//     cout << fixed << setprecision(15);
    #if _android
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif
}

template <class T = int> inline T readInt();
inline double readDouble();
inline int readUInt();
inline int readChar(); // first non-blank character
inline void readWord( char *s );
inline bool readLine( char *s ); // do not save '\n'
inline bool isEof();
inline int getChar();
inline int peekChar();
inline bool seekEof();
inline void skipBlanks();

template <class T> inline void writeInt( T x, char end = 0, int len = -1 );
inline void writeChar( int x );
inline void writeWord( const char *s );
inline void writeDouble( double x, int len = 0 );
inline void flush();

static struct buffer_flusher_t {
    ~buffer_flusher_t() {
        flush();
    }
} buffer_flusher;

/** Read */

static const int buf_size = 4096;

static unsigned char buf[buf_size];
static int buf_len = 0, buf_pos = 0;

inline bool isEof() {
    if (buf_pos == buf_len) {
        buf_pos = 0, buf_len = fread(buf, 1, buf_size, stdin);
        if (buf_pos == buf_len)
            return 1;
    }
    return 0;
}

inline int getChar() {
    return isEof() ? -1 : buf[buf_pos++];
}

inline int peekChar() {
    return isEof() ? -1 : buf[buf_pos];
}

inline bool seekEof() {
    int c;
    while ((c = peekChar()) != -1 && c <= 32)
        buf_pos++;
    return c == -1;
}

inline void skipBlanks() {
    while (!isEof() && buf[buf_pos] <= 32U)
        buf_pos++;
}

inline int readChar() {
    int c = getChar();
    while (c != -1 && c <= 32)
        c = getChar();
    return c;
}

inline int readUInt() {
    int c = readChar(), x = 0;
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return x;
}

template <class T>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    else if (c == '+')
        c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}

inline double readDouble() {
    int s = 1, c = readChar();
    double x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    if (c == '.') {
        c = getChar();
        double coef = 1;
        while ('0' <= c && c <= '9')
            x += (c - '0') * (coef *= 1e-1), c = getChar();
    }
    return s == 1 ? x : -x;
}

inline void readWord( char *s ) {
    int c = readChar();
    while (c > 32)
        *s++ = c, c = getChar();
    *s = 0;
}

inline bool readLine( char *s ) {
    int c = getChar();
    while (c != '\n' && c != -1)
        *s++ = c, c = getChar();
    *s = 0;
    return c != -1;
}

/** Write */

static int write_buf_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
    if (write_buf_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_buf_pos = 0;
    write_buf[write_buf_pos++] = x;
}

inline void flush() {
    if (write_buf_pos)
        fwrite(write_buf, 1, write_buf_pos, stdout), write_buf_pos = 0;
}

template <class T>
inline void writeInt( T x, char end, int output_len ) {
    if (x < 0)
        writeChar('-'), x = -x;

    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n < output_len)
        s[n++] = '0';
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}

inline void writeWord( const char *s ) {
    while (*s)
        writeChar(*s++);
}

inline void writeDouble( double x, int output_len ) {
    if (x < 0)
        writeChar('-'), x = -x;
    int t = (int)x;
    writeInt(t), x -= t;
    writeChar('.');
    for (int i = output_len - 1; i > 0; i--) {
        x *= 10;
        t = std::min(9, (int)x);
        writeChar('0' + t), x -= t;
    }
    x *= 10;
    t = std::min(9, (int)(x + 0.5));
    writeChar('0' + t);
}

matrix g;
bool used[200001];
int cnt[200001];
int c[200001];
vi nms;
int mx = -INF, ans = 0, sum = 0;

void dfs(int u) {
    used[u] = 1;
    cnt[c[u]]++;
    mx = max(mx, cnt[c[u]]);
    sum++;
    for(auto v : g[u]) {
        if(!used[v]) {
            dfs(v);
        }
    }
}

void dfs2(int u) {
    cnt[c[u]] = 0;
    for(auto v : g[u]) {
        if(cnt[c[v]] != 0)  {
            dfs2(v);
        }
    }
}

signed main() {
    seriy();
    int n, m, k;
    n = readInt();
    m = readInt();
    k = readInt();
//    cerr << m;
//    cnt.resize(k + 1);
//    readChar();
    g.resize(n);
//    used.resize(n);
//    c.resize(n);

    for(int i = 0; i < n; i++) {
        c[i] = readInt();
//        cerr << c[i];
    }
    int st;
    for(int i = 0; i < m; i++) {
        int u, v;
        u = readInt();
//        readChar();
        v = readInt();
        u--;
        v--;
        st = u;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(int i = 0; i < n; i++) {
        if(!used[i]) {
            sum = 0;
            mx = -INF;
            dfs2(i);
            dfs(i);
            ans += sum - mx;
        }
    }
    cout << ans;
    return 0;
}