Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. 

Ten minutes before her leave she realized that it would be also useful to prepare instruction of which particular clothes to wear on each of the days she will be absent. Arseniy's family is a bit weird so all the clothes is enumerated. For example, each of Arseniy's n socks is assigned a unique integer from 1 to n. Thus, the only thing his mother had to do was to write down two integers l_{i} and r_{i} for each of the days — the indices of socks to wear on the day i (obviously, l_{i} stands for the left foot and r_{i} for the right). Each sock is painted in one of k colors.

When mother already left Arseniy noticed that according to instruction he would wear the socks of different colors on some days. Of course, that is a terrible mistake cause by a rush. Arseniy is a smart boy, and, by some magical coincidence, he posses k jars with the paint — one for each of k colors.

Arseniy wants to repaint some of the socks in such a way, that for each of m days he can follow the mother's instructions and wear the socks of the same color. As he is going to be very busy these days he will have no time to change the colors of any socks so he has to finalize the colors now.

The new computer game Bota-3 was just realised and Arseniy can't wait to play it. What is the minimum number of socks that need their color to be changed in order to make it possible to follow mother's instructions and wear the socks of the same color during each of m days.


-----Input-----

The first line of input contains three integers n, m and k (2 ≤ n ≤ 200 000, 0 ≤ m ≤ 200 000, 1 ≤ k ≤ 200 000) — the number of socks, the number of days and the number of available colors respectively.

The second line contain n integers c_1, c_2, ..., c_{n} (1 ≤ c_{i} ≤ k) — current colors of Arseniy's socks.

Each of the following m lines contains two integers l_{i} and r_{i} (1 ≤ l_{i}, r_{i} ≤ n, l_{i} ≠ r_{i}) — indices of socks which Arseniy should wear during the i-th day.


-----Output-----

Print one integer — the minimum number of socks that should have their colors changed in order to be able to obey the instructions and not make people laugh from watching the socks of different colors.


-----Examples-----
Input
3 2 3
1 2 3
1 2
2 3

Output
2

Input
3 2 2
1 1 2
1 2
2 1

Output
0



-----Note-----

In the first sample, Arseniy can repaint the first and the third socks to the second color.

In the second sample, there is no need to change any colors.

Difficulty: interview

Starter code:

Solutions:
from collections import defaultdict

n, m, k = [int(x) for x in input().split()]
c = [0] + [int(x) for x in input().split()]
g = defaultdict(lambda: [])
for i in range(m):
    l, r = [int(x) for x in input().split()]
    g[l].append(r)
    g[r].append(l)
done = [0] * (1 + n)
ans = 0
for i in range(n):
    i += 1
    if done[i]:
        continue
    q = [i]
    p = 0
    mn = set([i])
    mcx = defaultdict(lambda: 0)
    while p != len(q):
        t = q[p]
        p += 1
        if done[t]:
            continue
        done[t] = 1
        mcx[c[t]] += 1
        mn.add(t)
        for ne in g[t]:
            q.append(ne)
    fcol = None
    maxn = -1
    for col, num in list(mcx.items()):
        if num >= maxn:
            maxn = num
            fcol = col
    if fcol:
        for ob in mn:
            if c[ob] != fcol and len(g[ob]) > 0:
                c[ob] = fcol
                ans += 1
print(ans)


import collections
class UnionFind:

    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.size = size
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        # 集合の代表を求める
        while self.table[x] >= 0:
            if self.table[self.table[x]] >= 0:
                self.table[x] = self.table[self.table[x]]
            x = self.table[x]
        return x

    def union(self, x, y):
        # 併合
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] >= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
        return self.table[s1]

    def count_group(self):
        count = 0
        for i in range(self.size):
            if self.table[i] < 0:
                count += 1
        return count

n,m,k = map(int, input().split())
c = [0] + list(map(int, input().split()))
uf = UnionFind(n+1)
use = [False] * (n+1)
for i in range(m):
    li,ri = map(int, input().split())
    uf.union(li, ri)
    use[li] = True
    use[ri] = True
groups = {}
for i in range(1,n+1):
    if not use[i]:
        continue
    g = uf.find(i)
    if g not in groups:
        groups.update({g:collections.defaultdict(int)})
    groups[g][c[i]] += 1
total = 0
for g in groups.values():
    total += sum(g.values()) - max(g.values())
print(total)

n, m, k = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

num = 0
clusters = {}
socks = {}

for i in range(m):
    l, r = [int(i) for i in input().split()]
    if l not in socks and r not in socks:
        socks[l] = num
        socks[r] = num
        clusters[num] = [l, r]
        num += 1
    elif l not in socks and r in socks:
        socks[l] = socks[r]
        clusters[socks[r]].append(l)
    elif l in socks and r not in socks:
        socks[r] = socks[l]
        clusters[socks[l]].append(r)
    elif socks[r] != socks[l]:
        clusters[socks[l]] += clusters[socks[r]]
        temp = socks[r] 
        for sock in clusters[socks[r]]:
            socks[sock] = socks[l]
        clusters.pop(temp)

to_paint = 0

for i in clusters:
    colors = {}
    ma = 0
    for sock in set(clusters[i]):
        k = c[sock - 1]
        if k in colors:
            colors[k] += 1
        else:
            colors[k] = 1
        if colors[k] > ma:
            ma = colors[k]
    to_paint += len(clusters[i]) - ma        

print(to_paint)

def main():
    from collections import defaultdict, Counter
    n, m, k = list(map(int, input().split()))
    n += 1
    cc = [0, *list(map(int, input().split()))]
    l = list(range(n))

    def find(x):
        while x != l[x]:
            x = l[x]
        return x

    for _ in range(m):
        a, b = list(map(int, input().split()))
        u, v = find(a), find(b)
        if u > v:
            l[u] = v
            while a != v:
                a, l[a] = l[a], v
        elif u < v:
            l[v] = u
            while b != u:
                b, l[b] = l[b], u
    groups = defaultdict(list)
    for i, c in enumerate(cc):
        l[i] = i = find(i)
        groups[i].append(c)
    for v in list(groups.values()):
        n -= Counter(v).most_common(1)[0][1] if len(l) > 1 else 1
    print(n)


def __starting_point():
    main()

__starting_point()

def main():
    from collections import defaultdict, Counter
    n, m, k = list(map(int, input().split()))
    n += 1
    cc = [0, *list(map(int, input().split()))]
    l = list(range(n))
    for _ in range(m):
        a, b = list(map(int, input().split()))
        u, v = a, b
        while u != l[u]:
            u = l[u]
        while v != l[v]:
            v = l[v]
        if u > v:
            l[u] = v
            while a != v:
                a, l[a] = l[a], v
        elif u < v:
            l[v] = u
            while b != u:
                b, l[b] = l[b], u
    groups = defaultdict(Counter)
    for i, g in enumerate(l):
        if i != g:
            l[i] = g = l[g]
            groups[g][cc[i]] += 1
    for g, v in list(groups.items()):
        v[cc[g]] += 1
    print(sum(sum(v.values()) - v.most_common(1)[0][1] for v in list(groups.values())))


def __starting_point():
    main()

__starting_point()

def main():
    from collections import Counter
    n, m, _ = list(map(int, input().split()))
    cc = list(map(int, input().split()))
    pairs, avail = [[] for _ in range(n)], [True] * n
    for _ in range(m):
        a, b = list(map(int, input().split()))
        pairs[a - 1].append(b - 1)
        pairs[b - 1].append(a - 1)
    for a, f in enumerate(avail):
        if f:
            stack, cnt, avail[a] = [a], Counter(), False
            while stack:
                a = stack.pop()
                cnt[cc[a]] += 1
                for b in pairs[a]:
                    if avail[b]:
                        avail[b] = False
                        stack.append(b)
            n -= cnt.most_common(1)[0][1]
    print(n)


def __starting_point():
    main()

__starting_point()

import sys
n, m, k = [int(x) for x in sys.stdin.readline().replace('\n', '').split(' ')]
c =  [int(x) for x in sys.stdin.readline().replace('\n', '').split(' ')]
# print ((n,m,k))
# Graphs with python
socks = [[] for _ in range(n)]
# populate a Graph
for i in range(m):
    l, r = [int(x)-1 for x in sys.stdin.readline().replace('\n', '').split(' ')]
    socks[r] += [l]
    socks[l] += [r]
# search a Graph
visited = [False for _ in range(n)]
forest = {}
for i, v in enumerate(visited):
    if v:
        continue
    visited[i] = True
    queue = [(i, i)]
    forest[i] = {'nodes': [i], 'colours': {c[i]: 1}}
    while len(queue) != 0:
        # print(queue)
        representant, current = queue.pop()
        for node in socks[current]:
            if not visited[node]:
                queue += [(representant, node)]
                forest[representant]['nodes'] += [node]
                if c[node] in forest[representant]['colours']:
                    forest[representant]['colours'][c[node]] += 1
                else:
                    forest[representant]['colours'][c[node]] = 1
                visited[node] = True
# print(forest)
total = 0
for key in forest:
    maximun = 0
    for i in forest[key]['colours']:
        if forest[key]['colours'][i] > maximun:
            maximun = forest[key]['colours'][i]
    total += len(forest[key]['nodes']) - maximun
sys.stdout.write(str(total))


import sys
n, m, k = [int(x) for x in sys.stdin.readline().replace('\n', '').split(' ')]
c =  [int(x) for x in sys.stdin.readline().replace('\n', '').split(' ')]
# print ((n,m,k))
# Graphs with python
socks = [[] for _ in range(n)]
# populate a Graph
for i in range(m):
    l, r = [int(x)-1 for x in sys.stdin.readline().replace('\n', '').split(' ')]
    socks[r] += [l]
    socks[l] += [r]
# search a Graph
visited = [False for _ in range(n)]
forest = {}
for i, v in enumerate(visited):
    if v:
        continue
    visited[i] = True
    queue = [(i, i)]
    forest[i] = {'nodes': 1, 'colours': {c[i]: 1}}
    while len(queue) != 0:
        # print(queue)
        representant, current = queue.pop()
        for node in socks[current]:
            if not visited[node]:
                queue += [(representant, node)]
                forest[representant]['nodes'] += 1
                if c[node] in forest[representant]['colours']:
                    forest[representant]['colours'][c[node]] += 1
                else:
                    forest[representant]['colours'][c[node]] = 1
                visited[node] = True
# print(forest)
total = 0
for key in forest:
    maximun = 0
    for i in forest[key]['colours']:
        if forest[key]['colours'][i] > maximun:
            maximun = forest[key]['colours'][i]
    total += forest[key]['nodes'] - maximun
sys.stdout.write(str(total))


from collections import Counter, defaultdict

class DSU:
	def __init__(self, n):
		self.parents = [i for i in range(n)]
		self.rank = [0 for i in range(n)]

	def find_parent(self, a):
		if a == self.parents[a]:
			return a
		else:
			b = self.find_parent(self.parents[a])
			self.parents[a] = b
			return b

	def join_sets(self, a, b):
		a = self.find_parent(a)
		b = self.find_parent(b)
		if a != b:
			if self.rank[a] < self.rank[b]:
				a, b = b, a
			self.parents[b] = a
			if self.rank[a] == self.rank[b]:
				self.rank[a] += 1

n, m, k = map(int, input().split(' '))
dsu = DSU(n)
colors = list(map(int, input().split(' ')))
for _ in range(m):
	a, b = map(int, input().split(' '))
	a, b = a-1, b-1
	dsu.join_sets(a, b)
cur_colors = defaultdict(Counter)
for i in range(n):
	cur_colors[dsu.find_parent(i)][colors[i]] += 1
ans = 0
for color_counter in cur_colors.values():
	ans += sum(color_counter.values()) - color_counter.most_common(1)[0][1]

print(ans)

def main():
    from collections import Counter
    n, m, _ = map(int, input().split())
    cc = list(map(int, input().split()))
    pairs, avail = [[] for _ in range(n)], [True] * n
    for _ in range(m):
        a, b = map(int, input().split())
        pairs[a - 1].append(b - 1)
        pairs[b - 1].append(a - 1)
    for a, f in enumerate(avail):
        if f:
            stack, cnt, avail[a] = [a], Counter(), False
            while stack:
                a = stack.pop()
                cnt[cc[a]] += 1
                for b in pairs[a]:
                    if avail[b]:
                        avail[b] = False
                        stack.append(b)
            n -= cnt.most_common(1)[0][1]
    print(n)


def __starting_point():
    main()
__starting_point()

def dfs(v, visited, edges, colors):
    st = [v]
    visited.add(v)
    comp = []
    cols = dict()
    while st:
        ver = st.pop()
        comp.append(colors[ver])
        if ver in edges:
            for i in edges[ver]:
                if i not in visited:
                    st.append(i)
                    visited.add(i)
    for i in comp:
        if i not in cols:
            cols[i] = 1
        else:
            cols[i] += 1
    max_c = 0
    for i in cols:
        if cols[i] > max_c:
            max_c = cols[i]
    return len(comp) - max_c



n, m, k = [int(x) for x in input().split()]
colors = {i + 1 : int(x) for i, x in enumerate(input().split())}
edges = dict()
for i in range(m):
    v1, v2 = [int(x) for x in input().split()]
    if v1 in edges:
        edges[v1].append(v2)
    else:
        edges[v1] = [v2]
    if v2 in edges:
        edges[v2].append(v1)
    else:
        edges[v2] = [v1]

visited = set()
answer = 0
for i in range(1, n + 1):
    if i not in visited:
        answer += dfs(i, visited, edges, colors)


print(answer)


from collections import deque, defaultdict

def BFS(graph, source, visited):
    # Generator which yields all vertices connected to source (includes source)
    n = len(graph)
    queue = deque()
    queue.append(source)
    visited[source] = True

    while len(queue) > 0:
        u = queue.popleft()
        yield u

        for v in graph[u]:
            if not visited[v]:
                visited[v] = True
                queue.append(v)

def get_components(adjacency_list, n):
    visited = [False] * n
    for i in range(n):
        if not visited[i]:
            yield list(BFS(adjacency_list, i, visited))

def __starting_point():
    n, m, k = list(map(int, input().split()))
    colours = [int(x) - 1 for x in input().split()]
    adjacency_list = [[] for _ in range(n)]
    for _ in range(m):
        l, r = (int(x) - 1 for x in input().split())
        adjacency_list[l].append(r)
        adjacency_list[r].append(l)

    components = get_components(adjacency_list, n)

    changes = 0
    for component in components:
        colour_counts = defaultdict(int)
        max_count = 0
        for sock in component:
            counter = colour_counts[colours[sock]] + 1
            colour_counts[colours[sock]] = counter
            if counter > max_count:
                max_count = counter

        changes += len(component) - max_count

    print(changes)

__starting_point()

from collections import deque, defaultdict

def BFS(graph, source, visited, colours):
    # Generator which yields all vertices connected to source (includes source)
    colour_counts = defaultdict(int)
    max_count = 0
    total = 0

    n = len(graph)
    queue = deque()
    queue.append(source)
    visited[source] = True

    while len(queue) > 0:
        u = queue.popleft()
        total += 1
        counter = colour_counts[colours[u]] + 1
        colour_counts[colours[u]] = counter
        if counter > max_count:
            max_count = counter

        for v in graph[u]:
            if not visited[v]:
                visited[v] = True
                queue.append(v)

    return total, max_count

def get_totals_and_maxcounts(adjacency_list, n, colours):
    visited = [False] * n
    for i in range(n):
        if not visited[i]:
            yield BFS(adjacency_list, i, visited, colours)

def __starting_point():
    n, m, k = list(map(int, input().split()))
    colours = [int(x) - 1 for x in input().split()]
    adjacency_list = [[] for _ in range(n)]
    for _ in range(m):
        l, r = (int(x) - 1 for x in input().split())
        adjacency_list[l].append(r)
        adjacency_list[r].append(l)


    changes = 0
    for total, max_count in get_totals_and_maxcounts(adjacency_list, n, colours):
        changes += total - max_count

    print(changes)

__starting_point()

n, m, k = list(map(int, input().split()))
socks = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

component = [None] * n
cur_comp = 0

for i in range(n):
    if component[i] is None:
        todo = [i]
        while todo:
            xi = todo.pop()
            component[xi] = cur_comp
            for neighbour in adj[xi]:
                if component[neighbour] is None:
                    todo.append(neighbour)
        cur_comp += 1

components = [[] for _ in range(cur_comp)]
for v, c in enumerate(component):
    components[c].append(v)

out = 0
for c in components:
    counter = {}
    for v in c:
        if socks[v] not in counter:
            counter[socks[v]] = 0
        counter[socks[v]] += 1
    out += len(c) - max(counter.values())
print(out)


class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
    def find(self,x):
        if self.parent[x] is x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        
    
def __starting_point():
    import sys, threading
class graph:
    def __init__(self, n):
        self.size = n
        self.adj = [[] for _ in range(n)]
        
    def add_edge(self,u,v):
        self.adj[u].append(v)
        self.adj[v].append(u)
        
    def DFS(self, node):
        self.visited[node] = True
        subg = [node]
        for edge in self.adj[node]:
            if not self.visited[edge]:
                subg.extend(self.DFS(edge))
        return subg
    
    def components(self):
        self.visited = [False]*self.size
        self.components = []    
        for node in range(self.size):
            if self.visited[node] is False:
                self.components.append(self.DFS(node))
        return self.components

def __starting_point():
    n, m, k = [int(x) for x in input().split()]
    uf = UnionFind(n)
    color = [int(x) for x in input().split()]
    for _ in range(m):
        u, v = [int(x) for x in input().split()]
        uf.union(u-1, v-1)
    collection = [[] for i in range(n)]
    for i in range(n):
        collection[uf.find(i)].append(i)

    ans = 0
    for sock_set in collection:
        if not sock_set: continue
        count = {}
        set_max = 1
        for sock in sock_set:
            try:
                count[color[sock]] += 1
                set_max = max(count[color[sock]], set_max)
            except:
                count[color[sock]] = 1
        ans += len(sock_set) - set_max

    print(ans)


__starting_point()

n, m, k = list(map(int, input().split()))
socks = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

component = [None] * n
cur_comp = 0

for i in range(n):
    if component[i] is None:
        todo = [i]
        while todo:
            xi = todo.pop()
            component[xi] = cur_comp
            for neighbour in adj[xi]:
                if component[neighbour] is None:
                    todo.append(neighbour)
        cur_comp += 1

components = [[] for _ in range(cur_comp)]
for v, c in enumerate(component):
    components[c].append(v)
out = 0
for c in components:
    counter = {}
    for v in c:
        if socks[v] not in counter:
            counter[socks[v]] = 0
        counter[socks[v]] += 1
    out += len(c) - max(counter.values())
print(out)


n, m, k = list(map(int, input().split()))
c = [int(x) - 1 for x in input().split()]

adj = [[] for _ in range(n)]
for _ in range(m):
    l, r = list(map(int, input().split()))
    adj[l - 1].append(r - 1)
    adj[r - 1].append(l - 1)

vis = [0] * n
ans = 0

for i in range(n):
    if vis[i] == 1: 
        continue

    arr, cur = [i], 0
    while cur < len(arr):
        v = arr[cur]
        vis[v] = 1
        cur += 1
        for nv in adj[v]:
            if vis[nv] == 0:
                arr.append(nv)
                vis[nv] = 1

    d = {}
    for v in arr:
        d[c[v]] = d.get(c[v], 0) + 1

    ans += len(arr) - max(d.values())

print(ans)    

    
    



def main():
    from collections import Counter
    n, m, _ = list(map(int, input().split()))
    cc = list(map(int, input().split()))
    pairs, avail = [[] for _ in range(n)], [True] * n
    for _ in range(m):
        a, b = list(map(int, input().split()))
        pairs[a - 1].append(b - 1)
        pairs[b - 1].append(a - 1)
    for a, f in enumerate(avail):
        if f:
            stack, cnt, avail[a] = [a], Counter(), False
            while stack:
                a = stack.pop()
                cnt[cc[a]] += 1
                for b in pairs[a]:
                    if avail[b]:
                        avail[b] = False
                        stack.append(b)
            n -= cnt.most_common(1)[0][1]
    print(n)


def __starting_point():
    main()




# Made By Mostafa_Khaled

__starting_point()

n,m,k=map(int,input().split())
c=list(map(int,input().split()))
g=[[]for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    g[l-1].append(r-1)
    g[r-1].append(l-1)
v=[-1]*n
o=0
for i in range(n):
    if v[i]==-1:
        s=[i]
        v[i]=1
        q={}
        while s:
            x=s.pop()
            if c[x] not in q:q[c[x]]=0
            q[c[x]]+=1
            for j in g[x]:
                if v[j]==-1:
                    v[j]=1
                    s.append(j)
        r,k=0,0
        for b in q:
            k=max(k,q[b])
            r+=q[b]
        o+=r-k
print(o)

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
tr=[[] for i in range(n)]

for i in range(m):
	l,r=map(int,input().split())
	tr[l-1].append(r-1)
	tr[r-1].append(l-1)
visited=[False for i in range(n)]
ans=0
for i in range(n):
	if visited[i]:continue
	s=[i]
	visited[i]=True
	qeue={}
	while s:
		x=s.pop()
		if a[x] not in qeue:qeue[a[x]]=0
		qeue[a[x]]+=1
		for j in tr[x]:
			if visited[j]:continue
			visited[j]=True
			s.append(j)
	neu,maxi=0,0
	for e in qeue:
		maxi=max(maxi,qeue[e])
		neu+=qeue[e]
	ans+=neu-maxi
print(ans)

import sys
input = sys.stdin.readline
from collections import defaultdict

class Unionfind:
    def __init__(self, n):
        self.par = [-1]*n
        self.rank = [1]*n
    
    def root(self, x):
        p = x
        
        while not self.par[p]<0:
            p = self.par[p]
        
        while x!=p:
            tmp = x
            x = self.par[x]
            self.par[tmp] = p
        
        return p
    
    def unite(self, x, y):
        rx, ry = self.root(x), self.root(y)
        
        if rx==ry: return False
        
        if self.rank[rx]<self.rank[ry]:
            rx, ry = ry, rx
        
        self.par[rx] += self.par[ry]
        self.par[ry] = rx
    
        if self.rank[rx]==self.rank[ry]:
            self.rank[rx] += 1
    
    def is_same(self, x, y):
        return self.root(x)==self.root(y)
    
    def count(self, x):
        return -self.par[self.root(x)]
        
n, m, k = list(map(int, input().split()))
c = list(map(int, input().split()))
uf = Unionfind(n)

for _ in range(m):
    l, r = list(map(int, input().split()))
    uf.unite(l-1, r-1)

cnt = defaultdict(dict)

for i in range(n):
    r = uf.root(i)
    
    if c[i] not in cnt[r]:
        cnt[r][c[i]] = 1
    else:
        cnt[r][c[i]] += 1

ans = 0

for r in list(cnt.keys()):
    l = list(cnt[r].values())
    ans += sum(l)-max(l)

print(ans)


from collections import *
from sys import stdin


def arr_inp(n):
    if n == 1:
        return [int(x) for x in stdin.readline().split()]
    elif n == 2:
        return [float(x) for x in stdin.readline().split()]
    else:
        return list(stdin.readline()[:-1])


class graph:
    # initialize graph
    def __init__(self, gdict=None):
        if gdict is None:
            gdict = defaultdict(list)
        self.gdict, self.edges, self.l = gdict, [], defaultdict(int)

    # Get verticies
    def get_vertices(self):
        return list(self.gdict.keys())

    # add edge
    def add_edge(self, node1, node2, w=None):
        self.gdict[node1].append(node2)
        self.gdict[node2].append(node1)
        self.l[node1] += 1
        self.l[node2] += 1

    def bfs_util(self, i):
        queue, self.visit[i], color = deque([i]), 1, defaultdict(int, {c[i - 1]: 1})

        while queue:
            # dequeue parent vertix
            s = queue.popleft()

            # enqueue child vertices
            for i in self.gdict[s]:
                if self.visit[i] == 0:
                    queue.append(i)
                    self.visit[i] = 1
                    color[c[i - 1]] += 1
        # print(color)
        return sum(color.values()) - max(color.values())

    def bfs(self):
        self.visit, self.cnt = defaultdict(int), 0

        for i in self.get_vertices():
            if self.visit[i] == 0:
                self.cnt += self.bfs_util(i)

        return self.cnt


n, m, k = arr_inp(1)
c, g = arr_inp(1), graph()

for i in range(m):
    u, v = arr_inp(1)
    g.add_edge(u, v)

print(g.bfs())


n, m, k = list(map(int, input().split()))
c = list(map(int, input().split()))
c = list([x-1 for x in c])
adj = [[] for _ in range(n)]
edges = list(list(map(int, input().split())) for _ in range(m))
for u, v in edges:
    u -= 1 ; v -= 1
    adj[u].append(v)
    adj[v].append(u)

vis = [0] * n
res = 0
for i in range(n):
    if vis[i] == 1: 
        continue
    arr, curr = [i], 0
    while curr < len(arr):
        u = arr[curr]
        vis[u] = 1
        curr += 1
        for v in adj[u]:
            if vis[v] == 0:
                arr.append(v)
                vis[v] = 1
    d = {}
    for j in arr:
        d[c[j]] = d.get(c[j], 0) + 1
    res += len(arr) - max(d.values())
print(res)


def find(node):
    while p[node] != node:
        p[node] = p[p[node]]
        node = p[node]
    return node

def union(n1,n2):
    p1 = find(n1)
    p2 = find(n2)

    if p1 != p2: p[p1] = p2


n,m,k = map(int,input().split())
socks = list(map(int,input().split()))
p = [i for i in range(n)]
used = set()
for i in range(m):
    a,b = map(int,input().split())

    union(a-1,b-1)
    used.add(a-1)
    used.add(b-1)
cc = {}

for i in used:
    x = find(i)
    if x not in cc:
        cc[x] = []
        cc[x].append(socks[i])
    else:
        cc[x].append(socks[i])
ans = 0
for each in cc.values():
    each.sort()
    cnt = 1
    l = len(each)
    mx = 1
    for i in range(l-1):
        if each[i+1] != each[i]:
            mx = max(mx,cnt)
            cnt = 1
        else:
            cnt += 1
    mx = max(cnt,mx)
    ans += l - mx
print(ans)