import java.util.*;
import java.io.*;
public class MainClass
{
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[] A = new int[n];
        for (int i=0;i<n;i++)
            A[i] = in.nextInt();
        DSU DSU = new DSU(n);
        for (int i=0;i<n;i++)
            DSU.makeSet(i, A[i]);
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            DSU.unionSets(x, y);
        }
        HashSet<Integer> h = new HashSet<>();
        int ans = 0;
        for (int i=0;i<n;i++)
        {
            int x = DSU.findSet(i);
            if (!h.contains(x))
            {
                h.add(x);
                ArrayList<Integer> C = DSU.adj[x];
                int max = 0;
                for (int ii=0;ii<C.size();ii++)
                {
                    int jj = ii;
                    while (jj < C.size() && C.get(jj) == C.get(ii))
                        jj++;
                    max = Math.max(max, jj - ii);
                    ii = jj - 1;
                }
                ans += DSU.size[x] - max;
            }
        }
        System.out.println(ans);
    }
}
class DSU
{
    int[] parent;
    int[] size;
    ArrayList<Integer>[] adj;

    DSU(int n)
    {
        this.parent = new int[n];
        this.size = new int[n];
        Arrays.fill(parent, -1);
        adj = new ArrayList[n];
    }

    public void makeSet(int v, int color)
    {
        parent[v] = v;
        size[v] = 1;
        adj[v] = new ArrayList<>();
        adj[v].add(color);
    }

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

    public void unionSets(int a, int b)
    {
        a = findSet(a);
        b = findSet(b);
        if (a != b)
        {
            if (size[a] < size[b])
            {
                int temp = a;
                a = b;
                b = temp;
            }
            parent[b] = a;
            size[a] += size[b];
            int i = 0;
            int j = 0;
            ArrayList<Integer> C = new ArrayList<>();
            while (i < adj[a].size() && j < adj[b].size())
            {
                if (adj[a].get(i) < adj[b].get(j))
                {
                    C.add(adj[a].get(i++));
                }
                else
                {
                    C.add(adj[b].get(j++));
                }
            }
            while (i < adj[a].size())
                C.add(adj[a].get(i++));
            while (j < adj[b].size())
                C.add(adj[b].get(j++));
            adj[a].clear();
            adj[a].addAll(C);
        }
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


import java.util.*;
import java.io.*;
public class MainClass
{
    static int[] count;
    static ArrayList<Integer>[] adj;
    static boolean[] visited;
    static int max = 0;
    static int size = 0;
    static int[] A;
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        A = new int[n];
        for (int i=0;i<n;i++)
            A[i] = in.nextInt() - 1;
        count = new int[k];
        adj = new ArrayList[n];
        visited = new boolean[n];
        for (int i=0;i<n;i++)
            adj[i] = new ArrayList<>();
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            adj[x].add(y);
            adj[y].add(x);
        }
        int ans = 0;
        for (int i=0;i<n;i++)
        {
            if (!visited[i])
            {
                size = 1;
                max = 1;
                explore(i);
                ans += size - max;
            }
        }
        System.out.println(ans);
    }
    public static void explore(int v)
    {
        visited[v] = true;
        size++;
        count[A[v]]++;
        max = Math.max(max, count[A[v]]);
        for (int u: adj[v]) if (!visited[u])    explore(u);
        count[A[v]]--;
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


import java.util.*;
import java.io.*;
public class MainClass
{
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[] A = new int[n];
        for (int i=0;i<n;i++)
            A[i] = in.nextInt();
        int[] p1 = new int[m];
        int[] p2 = new int[m];
        DSU DSU = new DSU(n);
        for (int i=0;i<n;i++)
            DSU.makeSet(i, A[i]);
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            DSU.unionSets(x, y);
        }
        HashSet<Integer> h = new HashSet<>();
        int ans = 0;
        for (int i=0;i<n;i++)
        {
            int x = DSU.findSet(i);
            if (!h.contains(x))
            {
                h.add(x);
                ans += DSU.size[x] - DSU.max[x];
            }
        }
        System.out.println(ans);
    }
}
class DSU
{
    int[] parent;
    int[] size;
    HashMap<Integer, Integer>[] adj;
    int max[];

    DSU(int n)
    {
        this.parent = new int[n];
        this.size = new int[n];
        Arrays.fill(parent, -1);
        adj = new HashMap[n];
        max = new int[n];
    }

    public void makeSet(int v, int color)
    {
        parent[v] = v;
        size[v] = 1;
        adj[v] = new HashMap<>();
        adj[v].put(color, 1);
        max[v] = 1;
    }

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

    public void unionSets(int a, int b)
    {
        a = findSet(a);
        b = findSet(b);
        if (a != b)
        {
            if (size[a] < size[b])
            {
                int temp = a;
                a = b;
                b = temp;
            }
            parent[b] = a;
            size[a] += size[b];
            HashMap<Integer, Integer> h2 = new HashMap<>();
            for (int i: adj[a].keySet())
            {
                if (adj[b].containsKey(i))
                {
                    int val = adj[a].get(i) + adj[b].get(i);
                    h2.put(i, val);
                    max[a] = Math.max(max[a], val);
                }
                else
                {
                    int val = adj[a].get(i);
                    h2.put(i, val);
                    max[a] = Math.max(max[a], val);
                }
            }
            for (int i: adj[b].keySet())
            {
                if (!adj[a].containsKey(i))
                {
                    int val = adj[b].get(i);
                    h2.put(i, val);
                    max[a] = Math.max(max[a], val);
                }
            }
            adj[a] = h2;
        }
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


import java.util.*;
import java.io.*;
public class MainClass
{
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[] A = new int[n];
        for (int i=0;i<n;i++)
            A[i] = in.nextInt();
        DSU DSU = new DSU(n);
        for (int i=0;i<n;i++)
            DSU.makeSet(i, A[i]);
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            DSU.unionSets(x, y);
        }
        HashSet<Integer> h = new HashSet<>();
        int ans = 0;
        for (int i=0;i<n;i++)
        {
            int x = DSU.findSet(i);
            if (!h.contains(x))
            {
                h.add(x);
                ArrayList<Integer> C = DSU.adj[x];
                int max = 1;
                for (int ii=0;ii<C.size();ii++)
                {
                    int jj = ii;
                    while (jj < C.size() && (int)C.get(jj) == (int)C.get(ii)) jj++;
                    max = Math.max(max, jj - ii);
                    ii = jj - 1;
                }
                ans += DSU.size[x] - max;
            }
        }
        System.out.println(ans);
    }
}
class DSU
{
    int[] parent;
    int[] size;
    ArrayList<Integer>[] adj;

    DSU(int n)
    {
        this.parent = new int[n];
        this.size = new int[n];
        Arrays.fill(parent, -1);
        adj = new ArrayList[n];
    }

    public void makeSet(int v, int color)
    {
        parent[v] = v;
        size[v] = 1;
        adj[v] = new ArrayList<>();
        adj[v].add(color);
    }

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

    public void unionSets(int a, int b)
    {
        a = findSet(a);
        b = findSet(b);
        if (a != b)
        {
            if (size[a] < size[b])
            {
                int temp = a;
                a = b;
                b = temp;
            }
            parent[b] = a;
            size[a] += size[b];
            int i = 0;
            int j = 0;
            ArrayList<Integer> C = new ArrayList<>();
            while (i < adj[a].size() && j < adj[b].size())
            {
                if (adj[a].get(i) < adj[b].get(j))
                {
                    C.add(adj[a].get(i++));
                }
                else
                {
                    C.add(adj[b].get(j++));
                }
            }
            while (i < adj[a].size())
                C.add(adj[a].get(i++));
            while (j < adj[b].size())
                C.add(adj[b].get(j++));
            adj[a].clear();
            adj[a].addAll(C);
        }
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


import java.util.*;
import java.io.*;
public class MainClass
{
    static int[] count;
    static ArrayList<Integer>[] adj;
    static boolean[] visited;
    static int max = 0;
    static int size = 0;
    static int[] A;
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        A = new int[n];
        for (int i=0;i<n;i++)
            A[i] = in.nextInt() - 1;
        count = new int[k];
        adj = new ArrayList[n];
        visited = new boolean[n];
        for (int i=0;i<n;i++)
            adj[i] = new ArrayList<>();
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            adj[x].add(y);
            adj[y].add(x);
        }
        int ans = 0;
        for (int i=0;i<n;i++)
        {
            if (!visited[i])
            {
                size = 0;
                max = 0;
                explore(i);
                ans += size - max;
            }
        }
        System.out.println(ans);
    }
    public static void explore(int v)
    {
        visited[v] = true;
        size++;
        count[A[v]]++;
        max = Math.max(max, count[A[v]]);
        for (int u: adj[v]) if (!visited[u])    explore(u);
        count[A[v]]--;
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


import java.util.*;
import java.io.*;
public class MainClass
{
    static int[] count;
    static ArrayList<Integer>[] adj;
    static boolean[] visited;
    static int max = 0;
    static int size = 0;
    static int[] A;
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        A = new int[n];
        for (int i=0;i<n;i++)
            A[i] = in.nextInt() - 1;
        count = new int[k];
        adj = new ArrayList[n];
        visited = new boolean[n];
        for (int i=0;i<n;i++)
            adj[i] = new ArrayList<>();
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            adj[x].add(y);
            adj[y].add(x);
        }
        int ans = 0;
        for (int i=0;i<n;i++)
        {
            if (!visited[i])
            {
                size = 0;
                max = 1;
                explore(i);
                ans += size - max;
            }
        }
        System.out.println(ans);
    }
    public static void explore(int v)
    {
        visited[v] = true;
        size++;
        count[A[v]]++;
        max = Math.max(max, count[A[v]]);
        for (int u: adj[v]) if (!visited[u])    explore(u);
        count[A[v]] = 0;
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private static int dfs(ArrayList<List<Integer>> graphs, boolean[] isVisit, int node) {
        int size = 0;

        Stack<Integer> stack = new Stack<>();
        stack.push(node);

        while (!stack.isEmpty()) {
            node = stack.pop();
            if (isVisit[node]) {
                continue;
            }
            isVisit[node] = true;
            size++;
            for (int nextNode: graphs.get(node)) {
                stack.push(nextNode);
            }
        }

        return size;
    }

    public static int solution(ArrayList<List<Integer>> graphs, int colors) {
        boolean[] isVisit = new boolean[colors + 1];
        int sum = 0;

        for (int i = 1; i < colors; ++i) {
            int size = dfs(graphs, isVisit, i);
            if (size > 0) {
                sum += size - 1;
            }
        }

        return sum;
    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int m = sc.nextInt();

        // init graph
        int k = sc.nextInt();
        ArrayList<List<Integer>> graphs = new ArrayList<List<Integer>>(n + 1);
        for (int i = 0; i <= n; ++i) {
            List<Integer> list = new LinkedList<>();
            graphs.add(i, list);
        }

        // init socks
        int[] socks = new int[n + 1];
        for (int i = 1; i <= n; ++i)  {
            socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            if (socks[e1] != socks[e2]) {
                graphs.get(e1).add(e2);
                graphs.get(e2).add(e1);
            }
        }
        pw.print(solution(graphs, n));
        pw.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static class Solution {
        int n, maxDuplicate, size;
        boolean[] isVisit;
        int[] socks;
        ArrayList<List<Integer>> graphs;
        HashMap<Integer, Integer> counter;

        private void dfs(int node) {
            isVisit[node] = true;
            size++;
            int color = socks[node];
            int newValue = counter.getOrDefault(color, 0) + 1;
            counter.put(color, newValue);
            maxDuplicate = Math.max(maxDuplicate, newValue);
            for (int n: graphs.get(node)) {
                if (!isVisit[n]) {
                    dfs(n);
                }
            }
        }

        public int solve() {
            isVisit = new boolean[n + 1];
            counter = new HashMap<Integer, Integer>(n + 1, 1.0f);

            int sum = 0;
            for (int i = 1; i <= n; ++i) {
                if (isVisit[i]) {
                    continue;
                }
                counter.clear();
                maxDuplicate = 0;
                size = 0;
                dfs(i);
                sum += size - maxDuplicate;
            }

            return sum;
        }

    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        Solution s = new Solution();

        s.n = sc.nextInt();
        int m = sc.nextInt();

        // init graph
        int k = sc.nextInt();
        s.graphs = new ArrayList<List<Integer>>(s.n + 1);
        for (int i = 0; i <= s.n; ++i) {
            List<Integer> list = new LinkedList<>();
            s.graphs.add(i, list);
        }

        // init socks
        s.socks = new int[s.n + 1];
        for (int i = 1; i <= s.n; ++i)  {
            s.socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            s.graphs.get(e1).add(e2);
            s.graphs.get(e2).add(e1);
        }
        pw.print(s.solve());
        pw.close();
    }
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Stream;

/**
 * @author ramilagger
 */
public class Main {

    final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    boolean[] visited;
    int cnt,max;
    int[] col;
    HashMap<Integer,Integer> map;
    ArrayList<Integer>[] adj;

    void dfs(int v) {
        visited[v] = true;
        cnt++;
        Integer c = map.get(col[v]);
        int cnt = c == null ? 1 : c + 1;
        map.put(col[v],cnt);
        max = Math.max(max,cnt);
        for (int i : adj[v])
            if (!visited[i])
                dfs(i);
    }

    void solve() {
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        col = nextArray(n);
        adj = Stream.generate(ArrayList::new)
                .limit(n).toArray(ArrayList[]::new);
        for (int i = 0; i < m; i++) {
            int l = nextInt() - 1;
            int r = nextInt() - 1;
            adj[l].add(r);
            adj[r].add(l);
        }
        int ans = 0;
        visited = new boolean[n];
        map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            cnt = 0;
            max = -1;
            map.clear();
            if(!visited[i]) {
                dfs(i);
                ans += (cnt - max);
            }
        }
        pw.println(ans);
    }

    public void run() throws IOException {
        start = System.currentTimeMillis();
        solve();
        if (!ONLINE_JUDGE)
            System.err.println(System.currentTimeMillis() - start + " ms");
        br.close();
        pw.close();
    }

    public Main() {
        try {
            br = (ONLINE_JUDGE) ? new BufferedReader(new InputStreamReader(System.in))
                    : new BufferedReader(new FileReader("in.txt"));
            pw = (ONLINE_JUDGE) ? new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))
                    : new PrintWriter(new BufferedWriter(new FileWriter("out.txt")));
            this.run();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }

    public static void main(String[] args) {
        new Main();
    }

    public boolean hasNext() {
        if (st != null && st.hasMoreTokens())
            return true;
        try {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    public String next() {
        if (hasNext()) return st.nextToken();
        return null;
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public BigInteger nextBigInteger() {
        return new BigInteger(next());
    }

    public String nextLine() {
        StringBuilder sb;
        try {
            while (st == null || !st.hasMoreTokens()) return br.readLine();
            sb = new StringBuilder(st.nextToken());
            while (st.hasMoreTokens()) sb.append(" " + st.nextToken());
        } catch (IOException e) {
            throw new RuntimeException();
        }
        return sb.toString();
    }

    public int[] nextArray(int n) {
        int[] temp = new int[n];
        for (int i = 0; i < n; i++)
            temp[i] = nextInt();
        return temp;
    }

    public long[] nextLArray(int n) {
        long[] temp = new long[n];
        for (int i = 0; i < n; i++)
            temp[i] = nextLong();
        return temp;
    }

    long start;
    final BufferedReader br;
    final PrintWriter pw;
    StringTokenizer st;

}


import java.io.*;
import java.util.*;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private static int dfs(ArrayList<List<Integer>> graphs, boolean[] isVisit, int node) {
        HashMap<Integer, Integer> counter = new HashMap<Integer, Integer>(isVisit.length);
        int maxDuplicate = 0;
        int size = 0;

        Stack<Integer> stack = new Stack<>();
        stack.push(node);

        while (!stack.isEmpty()) {
            node = stack.pop();
            if (isVisit[node]) {
                continue;
            }

            int newCounter = counter.getOrDefault(node, 0) + 1;
            counter.put(node, newCounter);
            maxDuplicate = Math.max(newCounter, maxDuplicate);

            isVisit[node] = true;
            size++;
            for (int nextNode: graphs.get(node)) {
                stack.push(nextNode);
            }
        }

        return size - maxDuplicate;
    }

    public static int solution(ArrayList<List<Integer>> graphs, int n) {
        boolean[] isVisit = new boolean[n + 1];
        int sum = 0;

        for (int i = 1; i <= n; ++i) {
            if (isVisit[i]) {
                continue;
            }
            int size = dfs(graphs, isVisit, i);
            sum += size;
        }

        return sum;
    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int m = sc.nextInt();

        // init graph
        int k = sc.nextInt();
        ArrayList<List<Integer>> graphs = new ArrayList<List<Integer>>(n + 1);
        for (int i = 0; i <= n; ++i) {
            List<Integer> list = new LinkedList<>();
            graphs.add(i, list);
        }

        // init socks
        int[] socks = new int[n + 1];
        for (int i = 1; i <= n; ++i)  {
            socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            graphs.get(e1).add(e2);
            graphs.get(e2).add(e1);
        }
        pw.print(solution(graphs, n));
        pw.close();
    }
}


import java.io.*;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static class Solution {
        int n, maxDuplicate, size;
        boolean[] isVisit;
        int[] socks;
        ArrayList<Integer>[] graphs;
        HashMap<Integer, Integer> counter;

        private void dfs(int node) {
            isVisit[node] = true;
            size++;
            int color = socks[node];
            int newValue = counter.getOrDefault(color, 0) + 1;
            counter.put(color, newValue);
            maxDuplicate = Math.max(maxDuplicate, newValue);
            for (int n: graphs[node]) {
                if (!isVisit[n]) {
                    dfs(n);
                }
            }
        }

        public int solve() {
            isVisit = new boolean[n + 1];
            counter = new HashMap<Integer, Integer>(n + 1, 1.0f);

            int sum = 0;
            for (int i = 1; i <= n; ++i) {
                if (isVisit[i]) {
                    continue;
                }
                counter.clear();
                maxDuplicate = 0;
                size = 0;
                dfs(i);
                sum += size - maxDuplicate;
            }

            return sum;
        }

    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        Solution s = new Solution();

        s.n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        s.graphs = Stream.generate(ArrayList::new).limit(s.n + 1).toArray(ArrayList[]::new);

        // init socks
        s.socks = new int[s.n + 1];
        for (int i = 1; i <= s.n; ++i)  {
            s.socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            s.graphs[e1].add(e2);
            s.graphs[e2].add(e1);
        }
        pw.print(s.solve());
        pw.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private static int dfs(ArrayList<List<Integer>> graphs, boolean[] isVisit, int node) {
        int size = 0;

        Stack<Integer> stack = new Stack<>();
        stack.push(node);

        while (!stack.isEmpty()) {
            node = stack.pop();
            if (isVisit[node]) {
                continue;
            }
            isVisit[node] = true;
            size++;
            for (int nextNode: graphs.get(node)) {
                stack.push(nextNode);
            }
        }

        return size;
    }

    public static int solution(ArrayList<List<Integer>> graphs, int colors) {
        boolean[] isVisit = new boolean[colors + 1];
        int sum = 0;

        for (int i = 1; i < colors; ++i) {
            int size = dfs(graphs, isVisit, i);
            if (size > 0) {
                sum += size - 1;
            }
        }

        return sum;
    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int m = sc.nextInt();

        // init graph
        int k = sc.nextInt();
        ArrayList<List<Integer>> graphs = new ArrayList<List<Integer>>(k + 1);
        for (int i = 0; i <= k; ++i) {
            List<Integer> list = new LinkedList<>();
            graphs.add(i, list);
        }

        // init socks
        int[] socks = new int[n + 1];
        for (int i = 1; i <= n; ++i)  {
            socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = socks[sc.nextInt()];
            int e2 = socks[sc.nextInt()];
            if (e1 != e2) {
                graphs.get(e1).add(e2);
                graphs.get(e2).add(e1);
            }
        }
        pw.print(solution(graphs, k));
        pw.close();
    }
}


import java.io.*;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public boolean hasNext() {
            if (st != null && st.hasMoreTokens())
                return true;
            try {
                while (st == null || !st.hasMoreTokens())
                    st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return false;
            }
            return true;
        }

        public String nextLine() {
            StringBuilder sb;
            try {
                while (st == null || !st.hasMoreTokens()) return br.readLine();
                sb = new StringBuilder(st.nextToken());
                while (st.hasMoreTokens()) sb.append(" " + st.nextToken());
            } catch (IOException e) {
                throw new RuntimeException();
            }
            return sb.toString();
        }

        public String next() {
            if (hasNext()) return st.nextToken();
            return null;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static class Solution {
        int n, k, maxDuplicate, size;
        boolean[] isVisit;
        int[] socks;
        int[] counter;
        ArrayList<Integer>[] graphs;

        private void dfs(int node) {
            isVisit[node] = true;
            size++;
            counter[socks[node]]++;
            maxDuplicate = Math.max(maxDuplicate, counter[socks[node]]);
            for (int n: graphs[node]) {
                if (!isVisit[n]) dfs(n);
            }
        }

        public int solve() {
            isVisit = new boolean[n + 1];
            counter = new int[k + 1];

            int sum = 0;
            for (int i = 1; i <= n; ++i) {
                if (!isVisit[i]) {
                    Arrays.fill(counter, 0);
                    maxDuplicate = 0;
                    size = 0;
                    dfs(i);
                    sum += size - maxDuplicate;
                }
            }

            return sum;
        }

    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        Solution s = new Solution();

        s.n = sc.nextInt();
        int m = sc.nextInt();
        s.k = sc.nextInt();
        s.graphs = Stream.generate(ArrayList::new).limit(s.n + 1).toArray(ArrayList[]::new);

        // init socks
        s.socks = new int[s.n + 1];
        for (int i = 1; i <= s.n; ++i)  {
            s.socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            s.graphs[e1].add(e2);
            s.graphs[e2].add(e1);
        }
        pw.print(s.solve());
        pw.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private static int dfs(ArrayList<List<Integer>> graphs, boolean[] isVisit, int[] socks, int node) {
        HashMap<Integer, Integer> counter = new HashMap<Integer, Integer>(isVisit.length);
        int maxDuplicate = 0;
        int size = 0;

        Stack<Integer> stack = new Stack<>();
        stack.push(node);

        while (!stack.isEmpty()) {
            node = stack.pop();
            if (isVisit[node]) {
                continue;
            }

            int color = socks[node];
            int newCounter = counter.getOrDefault(color, 0) + 1;
            counter.put(color, newCounter);
            maxDuplicate = Math.max(newCounter, maxDuplicate);

            isVisit[node] = true;
            size++;
            for (int nextNode: graphs.get(node)) {
                stack.push(nextNode);
            }
        }

        return size - maxDuplicate;
    }

    public static int solution(ArrayList<List<Integer>> graphs, int[] socks, int n) {
        boolean[] isVisit = new boolean[n + 1];
        int sum = 0;

        for (int i = 1; i <= n; ++i) {
            if (isVisit[i]) {
                continue;
            }
            int size = dfs(graphs, isVisit, socks, i);
            sum += size;
        }

        return sum;
    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int m = sc.nextInt();

        // init graph
        int k = sc.nextInt();
        ArrayList<List<Integer>> graphs = new ArrayList<List<Integer>>(n + 1);
        for (int i = 0; i <= n; ++i) {
            List<Integer> list = new LinkedList<>();
            graphs.add(i, list);
        }

        // init socks
        int[] socks = new int[n + 1];
        for (int i = 1; i <= n; ++i)  {
            socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            if (socks[e1] != socks[e2]) {
                graphs.get(e1).add(e2);
                graphs.get(e2).add(e1);
            }
        }
        pw.print(solution(graphs, socks, n));
        pw.close();
    }
}


import java.io.*;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public boolean hasNext() {
            if (st != null && st.hasMoreTokens())
                return true;
            try {
                while (st == null || !st.hasMoreTokens())
                    st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return false;
            }
            return true;
        }

        public String nextLine() {
            StringBuilder sb;
            try {
                while (st == null || !st.hasMoreTokens()) return br.readLine();
                sb = new StringBuilder(st.nextToken());
                while (st.hasMoreTokens()) sb.append(" " + st.nextToken());
            } catch (IOException e) {
                throw new RuntimeException();
            }
            return sb.toString();
        }

        public String next() {
            if (hasNext()) return st.nextToken();
            return null;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static class Solution {
        int n, k, maxDuplicate, size;
        boolean[] isVisit;
        int[] socks;
        HashMap<Integer, Integer> counter;
        ArrayList<Integer>[] graphs;

        private void dfs(int node) {
            isVisit[node] = true;
            size++;
            int newValue = counter.getOrDefault(socks[node], 0) + 1;
            counter.put(socks[node], newValue);
            maxDuplicate = Math.max(maxDuplicate, newValue);
            for (int n: graphs[node]) {
                if (!isVisit[n]) dfs(n);
            }
        }

        public int solve() {
            isVisit = new boolean[n + 1];
            counter = new HashMap<>();

            int sum = 0;
            for (int i = 1; i <= n; ++i) {
                if (!isVisit[i]) {
                    counter.clear();
                    maxDuplicate = 0;
                    size = 0;
                    dfs(i);
                    sum += size - maxDuplicate;
                }
            }

            return sum;
        }

    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        Solution s = new Solution();

        s.n = sc.nextInt();
        int m = sc.nextInt();
        s.k = sc.nextInt();
        s.graphs = Stream.generate(ArrayList::new).limit(s.n + 1).toArray(ArrayList[]::new);

        // init socks
        s.socks = new int[s.n + 1];
        for (int i = 1; i <= s.n; ++i)  {
            s.socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            s.graphs[e1].add(e2);
            s.graphs[e2].add(e1);
        }
        pw.print(s.solve());
        pw.close();
    }
}


import java.io.*;
import java.util.*;

public class Main {
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static class Solution {
        int n;
        boolean[] isVisit;
        int[] socks;
        ArrayList<List<Integer>> graphs;
        HashMap<Integer, Integer> counter;

        private int dfs(int node) {
            int maxDuplicate = 0;
            int size = 0;

            Stack<Integer> stack = new Stack<>();
            stack.push(node);

            while (!stack.isEmpty()) {
                node = stack.pop();
                if (isVisit[node]) {
                    continue;
                }

                int color = socks[node];
                int newCounter = counter.getOrDefault(color, 0) + 1;
                counter.put(color, newCounter);
                maxDuplicate = Math.max(newCounter, maxDuplicate);
                isVisit[node] = true;
                size++;
                for (int nextNode: graphs.get(node)) {
                    stack.push(nextNode);
                }
            }

            return size - maxDuplicate;
        }

        public int solve() {
            isVisit = new boolean[n + 1];
            counter = new HashMap<Integer, Integer>(n + 1, 1.0f);

            int sum = 0;
            for (int i = 1; i <= n; ++i) {
                if (isVisit[i]) {
                    continue;
                }
                counter.clear();
                int size = dfs(i);
                sum += size;
            }

            return sum;
        }

    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        Solution s = new Solution();

        s.n = sc.nextInt();
        int m = sc.nextInt();

        // init graph
        int k = sc.nextInt();
        s.graphs = new ArrayList<List<Integer>>(s.n + 1);
        for (int i = 0; i <= s.n; ++i) {
            List<Integer> list = new LinkedList<>();
            s.graphs.add(i, list);
        }

        // init socks
        s.socks = new int[s.n + 1];
        for (int i = 1; i <= s.n; ++i)  {
            s.socks[i] = sc.nextInt();
        }

        // make graphs
        for (int i = 0; i < m; ++i) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            s.graphs.get(e1).add(e2);
            s.graphs.get(e2).add(e1);
        }
        pw.print(s.solve());
        pw.close();
    }
}


import java.util.*;

public class Main {

	static class TreeNode {
		int id;
		ArrayList<TreeNode> children = new ArrayList<>();

		TreeNode(int id) {
			this.id = id;
		}
	}

	static class UF {
		private Vector<Integer> p, rank, setSize;
		private HashMap<Integer, TreeNode> trees;
		private int numSets;

		public UF(int N) {
			p = new Vector<Integer>(N);
			rank = new Vector<Integer>(N);
			setSize = new Vector<Integer>(N);
			trees = new HashMap<>();
			numSets = N;
			for (int i = 0; i < N; i++) {
				p.add(i);
				rank.add(0);
				setSize.add(1);
				trees.put(i, new TreeNode(i));
			}
		}

		public int findSet(int i) {
			if (p.get(i) == i)
				return i;
			else {
				int ret = findSet(p.get(i));
				p.set(i, ret);
				return ret;
			}
		}

		public Boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}

		public void unionSet(int i, int j) {
			if (!isSameSet(i, j)) {
				numSets--;
				int x = findSet(i), y = findSet(j);
				// rank is used to keep the tree short
				if (rank.get(x) > rank.get(y)) {
					trees.get(x).children.add(trees.get(y));
					trees.remove(y);
					p.set(y, x);
					setSize.set(x, setSize.get(x) + setSize.get(y));
				} else {
					trees.get(y).children.add(trees.get(x));
					trees.remove(x);
					p.set(x, y);
					setSize.set(y, setSize.get(y) + setSize.get(x));
					if (rank.get(x) == rank.get(y))
						rank.set(y, rank.get(y) + 1);
				}
			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize.get(findSet(i));
		}
	}

	static ArrayList<Integer> set = new ArrayList<>();

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		int[] color = new int[n];
		for(int i = 0; i < n; i++) color[i] = in.nextInt() - 1;
		UF uf = new UF(n);
		for(int i = 0; i < m; i++) uf.unionSet(in.nextInt() - 1, in.nextInt() - 1);

		Iterator it = uf.trees.entrySet().iterator();
		int ans = 0;
		while(it.hasNext()) {
			set.clear();
			Map.Entry<Integer, TreeNode> pair = (Map.Entry<Integer, TreeNode>)it.next();
			dfs(pair.getValue());

			int[] freq = new int[k];
			int max = 0;
			for(Integer c : set)
				max = Math.max(max, ++freq[color[c]]);
			if(uf.sizeOfSet(pair.getKey()) > 1)
				ans += uf.sizeOfSet(pair.getKey()) - max;
		}
		System.out.println(ans);
	}

	public static void dfs(TreeNode tn) {
		set.add(tn.id);
		for(TreeNode n : tn.children) dfs(n);
	}

}


import java.io.*;
import java.util.*;

public class Socks {

	static class Node {
		int id;
		List<Node> adj;
		public Node(int id) { this.id = id; adj = new ArrayList<>(); }
	}

	static int[] sockColor;
	static int[] colorFreq;
	static boolean[] visited;
	static int max;
	static int sum;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int m = Integer.parseInt(line[1]);
		int k = Integer.parseInt(line[2]);
		sockColor = new int[n];
		colorFreq = new int[k];
		line = br.readLine().split(" ");
		for(int i = 0; i < n; i++) sockColor[i] = Integer.parseInt(line[i]) - 1;
		List<Node> socks = new ArrayList<>();
		for(int i = 0; i < n; i++) socks.add(new Node(i));
		for(int i = 0; i < m; i++) {
			line = br.readLine().split(" ");
			Node n1 = socks.get(Integer.parseInt(line[0]) - 1);
			Node n2 = socks.get(Integer.parseInt(line[1]) - 1);
			n1.adj.add(n2);
			n2.adj.add(n1);
		}
		visited = new boolean[n];
		Arrays.fill(visited, false);
		int ans = 0;
		for(Node s : socks) {
			if(!visited[s.id]) {
				sum = 0;
				max = 0;
				dfs(s);
				if(sum == 1) continue;
				ans += sum - max;
				Arrays.fill(colorFreq, 0);
			}
		}
		System.out.println(ans);
	}

	static void dfs(Node src) {
		if(visited[src.id]) return;
		visited[src.id] = true;
		sum++;
		max = Math.max(max, ++colorFreq[sockColor[src.id]]);
		for(Node n : src.adj) dfs(n);
	}

}


import java.util.*;

public class Main {

	static class TreeNode {
		int id;
		ArrayList<TreeNode> children = new ArrayList<>();

		TreeNode(int id) {
			this.id = id;
		}
	}

	static class UF {
		private Vector<Integer> p, rank, setSize;
		private HashMap<Integer, TreeNode> trees;
		private int numSets;

		public UF(int N) {
			p = new Vector<Integer>(N);
			rank = new Vector<Integer>(N);
			setSize = new Vector<Integer>(N);
			trees = new HashMap<>();
			numSets = N;
			for (int i = 0; i < N; i++) {
				p.add(i);
				rank.add(0);
				setSize.add(1);
				trees.put(i, new TreeNode(i));
			}
		}

		public int findSet(int i) {
			if (p.get(i) == i)
				return i;
			else {
				int ret = findSet(p.get(i));
				p.set(i, ret);
				return ret;
			}
		}

		public Boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}

		public void unionSet(int i, int j) {
			if (!isSameSet(i, j)) {
				numSets--;
				int x = findSet(i), y = findSet(j);
				// rank is used to keep the tree short
				if (rank.get(x) > rank.get(y)) {
					trees.get(x).children.add(trees.get(y));
					trees.remove(y);
					p.set(y, x);
					setSize.set(x, setSize.get(x) + setSize.get(y));
				} else {
					trees.get(y).children.add(trees.get(x));
					trees.remove(x);
					p.set(x, y);
					setSize.set(y, setSize.get(y) + setSize.get(x));
					if (rank.get(x) == rank.get(y))
						rank.set(y, rank.get(y) + 1);
				}
			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize.get(findSet(i));
		}
	}

	static int[] freq;
	static int[] color;
	static int max;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		color = new int[n];
		for(int i = 0; i < n; i++) color[i] = in.nextInt() - 1;
		UF uf = new UF(n);
		for(int i = 0; i < m; i++) uf.unionSet(in.nextInt() - 1, in.nextInt() - 1);

		Iterator it = uf.trees.entrySet().iterator();
		int ans = 0;
		while(it.hasNext()) {
			Map.Entry<Integer, TreeNode> pair = (Map.Entry<Integer, TreeNode>)it.next();
			freq = new int[k];
			max = 0;
			dfs(pair.getValue());
			if(uf.sizeOfSet(pair.getKey()) > 1)
				ans += uf.sizeOfSet(pair.getKey()) - max;
		}
		System.out.println(ans);
	}

	public static void dfs(TreeNode tn) {
		max = Math.max(max, ++freq[color[tn.id]]);
		for(TreeNode n : tn.children) dfs(n);
	}

}


import java.io.*;
import java.util.*;

public class Socks {

	static class Node {
		int id;
		List<Node> adj;
		public Node(int id) { this.id = id; adj = new ArrayList<>(); }
	}

	static int[] sockColor;
	static int[] colorFreq;
	static boolean[] visited;
	static int max;
	static int sum;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int m = Integer.parseInt(line[1]);
		int k = Integer.parseInt(line[2]);
		sockColor = new int[n];
		line = br.readLine().split(" ");
		for(int i = 0; i < n; i++) sockColor[i] = Integer.parseInt(line[i]) - 1;
		List<Node> socks = new ArrayList<>();
		for(int i = 0; i < n; i++) socks.add(new Node(i));
		for(int i = 0; i < m; i++) {
			line = br.readLine().split(" ");
			Node n1 = socks.get(Integer.parseInt(line[0]) - 1);
			Node n2 = socks.get(Integer.parseInt(line[1]) - 1);
			n1.adj.add(n2);
			n2.adj.add(n1);
		}
		visited = new boolean[n];
		Arrays.fill(visited, false);
		int ans = 0;
		for(Node s : socks) {
			if(!visited[s.id]) {
				colorFreq = new int[k];
				sum = 0;
				max = 0;
				dfs(s);
				if(sum == 1) continue;
				ans += sum - max;
			}
		}
		System.out.println(ans);
	}

	static void dfs(Node src) {
		if(visited[src.id]) return;
		visited[src.id] = true;
		sum++;
		max = Math.max(max, ++colorFreq[sockColor[src.id]]);
		for(Node n : src.adj) dfs(n);
	}

}


import java.util.*;
import java.io.*;

public class Main {

	static class TreeNode {
		int id;
		ArrayList<TreeNode> children = new ArrayList<>();

		TreeNode(int id) {
			this.id = id;
		}
	}

	static class UF {
		private Vector<Integer> p, rank, setSize;
		private HashMap<Integer, TreeNode> trees;
		private int numSets;

		public UF(int N) {
			p = new Vector<Integer>(N);
			rank = new Vector<Integer>(N);
			setSize = new Vector<Integer>(N);
			trees = new HashMap<>();
			numSets = N;
			for (int i = 0; i < N; i++) {
				p.add(i);
				rank.add(0);
				setSize.add(1);
				trees.put(i, new TreeNode(i));
			}
		}

		public int findSet(int i) {
			if (p.get(i) == i)
				return i;
			else {
				int ret = findSet(p.get(i));
				p.set(i, ret);
				return ret;
			}
		}

		public Boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}

		public void unionSet(int i, int j) {
			if (!isSameSet(i, j)) {
				numSets--;
				int x = findSet(i), y = findSet(j);
				// rank is used to keep the tree short
				if (rank.get(x) > rank.get(y)) {
					trees.get(x).children.add(trees.get(y));
					trees.remove(y);
					p.set(y, x);
					setSize.set(x, setSize.get(x) + setSize.get(y));
				} else {
					trees.get(y).children.add(trees.get(x));
					trees.remove(x);
					p.set(x, y);
					setSize.set(y, setSize.get(y) + setSize.get(x));
					if (rank.get(x) == rank.get(y))
						rank.set(y, rank.get(y) + 1);
				}
			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize.get(findSet(i));
		}
	}

	static int[] freq;
	static int[] color;
	static int max;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] l = br.readLine().split(" ");
		int n = Integer.parseInt(l[0]);
		int m = Integer.parseInt(l[1]);
		int k = Integer.parseInt(l[2]);
		color = new int[n];
		l = br.readLine().split(" ");
		for(int i = 0; i < n; i++) color[i] = Integer.parseInt(l[i]) - 1;
		UF uf = new UF(n);
		for(int i = 0; i < m; i++) {
			l = br.readLine().split(" ");
			uf.unionSet(Integer.parseInt(l[0]) - 1, Integer.parseInt(l[1]) - 1);
		}

		Iterator it = uf.trees.entrySet().iterator();
		int ans = 0;
		while(it.hasNext()) {
			Map.Entry<Integer, TreeNode> pair = (Map.Entry<Integer, TreeNode>)it.next();
			freq = new int[k];
			max = 0;
			dfs(pair.getValue());
			if(uf.sizeOfSet(pair.getKey()) > 1)
				ans += uf.sizeOfSet(pair.getKey()) - max;
		}
		System.out.println(ans);
	}

	public static void dfs(TreeNode tn) {
		max = Math.max(max, ++freq[color[tn.id]]);
		for(TreeNode n : tn.children) dfs(n);
	}

}


import java.io.*;
import java.util.*;

public class Socks {

	static class Node {
		int id;
		List<Node> adj;
		public Node(int id) { this.id = id; adj = new ArrayList<>(); }
	}

	static int[] sockColor;
	static int[] colorFreq;
	static boolean[] visited;
	static int max;
	static int sum;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int m = Integer.parseInt(line[1]);
		int k = Integer.parseInt(line[2]);
		sockColor = new int[n];
		colorFreq = new int[k];
		line = br.readLine().split(" ");
		for(int i = 0; i < n; i++) sockColor[i] = Integer.parseInt(line[i]) - 1;
		List<Node> socks = new ArrayList<>();
		for(int i = 0; i < n; i++) socks.add(new Node(i));
		for(int i = 0; i < m; i++) {
			line = br.readLine().split(" ");
			Node n1 = socks.get(Integer.parseInt(line[0]) - 1);
			Node n2 = socks.get(Integer.parseInt(line[1]) - 1);
			n1.adj.add(n2);
			n2.adj.add(n1);
		}
		visited = new boolean[n];
		Arrays.fill(visited, false);
		int ans = 0;
		for(Node s : socks) {
			if(!visited[s.id]) {
				sum = 0;
				max = 0;
				dfs(s);
				ans += sum - max;
			}
		}
		System.out.println(ans);
	}

	static void dfs(Node src) {
		if(visited[src.id]) return;
		visited[src.id] = true;
		sum++;
		max = Math.max(max, ++colorFreq[sockColor[src.id]]);
		for(Node n : src.adj) dfs(n);
	}

}


import java.io.*;
import java.util.*;

public class Socks {

	static class Node {
		int id;
		List<Node> adj;
		public Node(int id) { this.id = id; adj = new ArrayList<>(); }
	}

	static int[] sockColor;
	static HashMap<Integer, Integer> colorFreq;
	static boolean[] visited;
	static int max;
	static int sum;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int m = Integer.parseInt(line[1]);
		int k = Integer.parseInt(line[2]);
		sockColor = new int[n];
		line = br.readLine().split(" ");
		for(int i = 0; i < n; i++) sockColor[i] = Integer.parseInt(line[i]) - 1;
		List<Node> socks = new ArrayList<>();
		for(int i = 0; i < n; i++) socks.add(new Node(i));
		for(int i = 0; i < m; i++) {
			line = br.readLine().split(" ");
			Node n1 = socks.get(Integer.parseInt(line[0]) - 1);
			Node n2 = socks.get(Integer.parseInt(line[1]) - 1);
			n1.adj.add(n2);
			n2.adj.add(n1);
		}
		visited = new boolean[n];
		Arrays.fill(visited, false);
		colorFreq = new HashMap<>();
		int ans = 0;
		for(Node s : socks) {
			if(!visited[s.id]) {
				colorFreq.clear();
				sum = 0;
				max = 0;
				dfs(s);
				if(sum == 1) continue;
				ans += sum - max;
			}
		}
		System.out.println(ans);
	}

	static void dfs(Node src) {
		if(visited[src.id]) return;
		visited[src.id] = true;
		sum++;
		int freq = colorFreq.containsKey(sockColor[src.id]) ? colorFreq.get(sockColor[src.id]) + 1 : 1;
		colorFreq.put(sockColor[src.id], freq);
		max = Math.max(max, freq);
		for(Node n : src.adj) dfs(n);
	}

}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        InputStream inputStream = null;
//        try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    public void solve(int testNumber, InputReader in, PrintWriter out) {

        Integer socks = in.nextInt();
        Integer days = in.nextInt();
        Integer colors = in.nextInt();
        Map<Integer,Integer> sockToColor  = new HashMap<>(socks);

        for(int i=1; i<=socks; i++){
            sockToColor.put(i,in.nextInt());
        }

        DSU dsu = new DSU();

        for(int i=0; i<days; i++){
            Integer leftSock = in.nextInt();
            Integer rightSock = in.nextInt();
            dsu.makeSet(leftSock, sockToColor.get(leftSock));
            dsu.makeSet(rightSock, sockToColor.get(rightSock));
            dsu.mergeSets(leftSock,rightSock);
        }

        Integer sum = 0;
        for(Integer root : dsu.getRoots()){
            Map<Integer,Integer> colorMap = dsu.getColors(root);
            Integer toBeColored = dsu.getSetSize(root) - colorMap.values().stream().max(Integer::max).get();
            sum+=toBeColored;
        }
        out.println(sum);

    }

}

class DSU{
    private Map<Integer, Integer> parent;
    private Map<Integer, Map<Integer, Integer>> colorCount;
    private Map<Integer, Integer> setSize;
    private Set<Integer> roots;
    public DSU(){
        parent = new HashMap<>();
        colorCount = new HashMap<>();
        setSize = new HashMap<>();
        roots = new HashSet<>();
    }

    public void makeSet(Integer node, Integer color){
        if(parent.keySet().contains(node)) {
            return;
        }

        parent.put(node, null);
        roots.add(node);
        Map<Integer,Integer> colors = new HashMap<>();
        colors.put(color,1);
        colorCount.put(node,colors);
        setSize.put(node,1);
    }

    public Integer findParent(Integer node){
        if(!parent.keySet().contains(node)) {
            throw new IllegalArgumentException();
        }
        while(parent.get(node)!= null){
            node = parent.get(node);
        }
        return node;
    }

    public void mergeSets(Integer node1, Integer node2){
        node1 = findParent(node1);
        node2 = findParent(node2);

        if(node1.equals(node2)){
            return;
        }

        parent.put(node2, node1);
        setSize.put(node1, setSize.get(node1) + setSize.get(node2));
        roots.remove(node2);

        Map<Integer, Integer> node1Colors = colorCount.get(node1);
        Map<Integer, Integer> node2Colors = colorCount.get(node2);

        for(Integer color : node2Colors.keySet()){
            node1Colors.put(color, node1Colors.getOrDefault(color,0) + node2Colors.get(color));
        }
        colorCount.remove(node2);
        setSize.remove(node2);
    }

    public Integer getSetSize(Integer node){
        if(!roots.contains(node)){
            node = findParent(node);
        }
        return setSize.get(node);
    }

    public Map<Integer, Integer> getColors(Integer node){
        if(!roots.contains(node)){
            node = findParent(node);
        }
        return colorCount.get(node);
    }

    public Set<Integer> getRoots(){
        return  roots;
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}

class Pair<F, S> {
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        InputStream inputStream = null;
//        try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    public void solve(int testNumber, InputReader in, PrintWriter out) {

        Integer socks = in.nextInt();
        Integer days = in.nextInt();
        Integer colors = in.nextInt();
        int[] sockToColor = new int[socks+1];

        for(int i=1; i<=socks; i++){
            sockToColor[i]=in.nextInt();
        }

        boolean[] usedNodes = new boolean[socks+1];
        List<List<Integer>> edges = new ArrayList<>(socks+1);
        for(int i=0; i<=socks; i++){
            edges.add(new ArrayList<>(socks));
        }

        for(int i=0; i<days; i++){
            Integer leftSock = in.nextInt();
            Integer rightSock = in.nextInt();
            usedNodes[leftSock] = Boolean.TRUE;
            usedNodes[rightSock] = Boolean.TRUE;

            edges.get(leftSock).add(rightSock);
            edges.get(rightSock).add(leftSock);
        }

        Integer sum = 0;
        for(int node=1; node<=socks; node++){
            if(!usedNodes[node]){
                continue;
            }

            int [] colorCounts = new int[colors+1];
            Integer componentSize = 0;
            Queue<Integer> q = new ArrayDeque<>();
            q.add(node);

            while(!q.isEmpty()){
                Integer currentNode  = q.poll();
                if(!usedNodes[currentNode]){
                    continue;
                }
                usedNodes[currentNode] = Boolean.FALSE;
//                usedNodes.remove(currentNode);

                componentSize+=1;
                Integer nodeColor = sockToColor[currentNode];
                colorCounts[nodeColor]+=1;

                for(Integer target : edges.get(currentNode)){
                    q.add(target);
                }

            }

            sum+=componentSize - Arrays.stream(colorCounts).max().getAsInt();

        }

        out.println(sum);

    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}

class Pair<F, S> {
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        InputStream inputStream = null;
//        try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    public void solve(int testNumber, InputReader in, PrintWriter out) {

        Integer socks = in.nextInt();
        Integer days = in.nextInt();
        Integer colors = in.nextInt();
        Map<Integer,Integer> sockToColor  = new HashMap<>(socks);

        for(int i=1; i<=socks; i++){
            sockToColor.put(i,in.nextInt());
        }

        Set<Integer> usedNodes = new HashSet<>();
        Map<Integer, Set<Integer>> edges = new HashMap<>();
        for(int i=0; i<days; i++){
            Integer leftSock = in.nextInt();
            Integer rightSock = in.nextInt();
            usedNodes.add(leftSock);
            usedNodes.add(rightSock);
            Set<Integer> leftSockEdges = edges.getOrDefault(leftSock, new HashSet<>());
            Set<Integer> rightSockEdges = edges.getOrDefault(rightSock, new HashSet<>());
            leftSockEdges.add(rightSock);
            rightSockEdges.add(leftSock);
            edges.put(leftSock,leftSockEdges);
            edges.put(rightSock,rightSockEdges);
        }

        Integer sum = 0;
        while(!usedNodes.isEmpty()){
            Integer node = usedNodes.iterator().next();

            int [] colorCounts = new int[colors+1];
            Integer componentSize = 0;
            Queue<Integer> q = new ArrayDeque<>();
            q.add(node);

            Set<Integer> visited = new HashSet<>();
            while(!q.isEmpty()){
                Integer currentNode  = q.poll();
                if(!usedNodes.contains(currentNode)){
                    continue;
                }
                usedNodes.remove(currentNode);

                componentSize+=1;
                Integer nodeColor = sockToColor.get(currentNode);
                colorCounts[nodeColor]+=1;

                for(Integer target : edges.get(currentNode)){
                    q.add(target);
                }

            }

            sum+=componentSize - Arrays.stream(colorCounts).max().getAsInt();

        }

        out.println(sum);

    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}

class Pair<F, S> {
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        InputStream inputStream = null;
//        try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    public void solve(int testNumber, InputReader in, PrintWriter out) {

        Integer socks = in.nextInt();
        Integer days = in.nextInt();
        Integer colors = in.nextInt();
        Map<Integer,Integer> sockToColor  = new HashMap<>(socks);

        for(int i=1; i<=socks; i++){
            sockToColor.put(i,in.nextInt());
        }

        DSU dsu = new DSU();

        for(int i=0; i<days; i++){
            Integer leftSock = in.nextInt();
            Integer rightSock = in.nextInt();
            dsu.makeSet(leftSock, sockToColor.get(leftSock));
            dsu.makeSet(rightSock, sockToColor.get(rightSock));
            dsu.mergeSets(leftSock,rightSock);
        }

        Integer sum = 0;
        for(Integer root : dsu.getRoots()){
            Map<Integer,Integer> colorMap = dsu.getColors(root);
            Integer setSize = dsu.getSetSize(root);
            Integer maxColorCount =  Collections.max(colorMap.values());
            sum+=(setSize - maxColorCount);
        }
        out.println(sum);

    }

}

class DSU{
    private Map<Integer, Integer> parent;
    private Map<Integer, Map<Integer, Integer>> colorCount;
    private Map<Integer, Integer> setSize;
    private Set<Integer> roots;
    public DSU(){
        parent = new HashMap<>();
        colorCount = new HashMap<>();
        setSize = new HashMap<>();
        roots = new HashSet<>();
    }

    public void makeSet(Integer node, Integer color){
        if(parent.keySet().contains(node)) {
            return;
        }

        parent.put(node, null);
        roots.add(node);
        Map<Integer,Integer> colors = new HashMap<>();
        colors.put(color,1);
        colorCount.put(node,colors);
        setSize.put(node,1);
    }

    public Integer findParent(Integer node){
        if(!parent.keySet().contains(node)) {
            throw new IllegalArgumentException();
        }
        while(parent.get(node)!= null){
            node = parent.get(node);
        }
        return node;
    }

    public void mergeSets(Integer node1, Integer node2){
        node1 = findParent(node1);
        node2 = findParent(node2);

        if(node1.equals(node2)){
            return;
        }

        parent.put(node2, node1);
        setSize.put(node1, setSize.get(node1) + setSize.get(node2));
        roots.remove(node2);

        Map<Integer, Integer> node1Colors = colorCount.get(node1);
        Map<Integer, Integer> node2Colors = colorCount.get(node2);

        for(Integer color : node2Colors.keySet()){
            node1Colors.put(color, node1Colors.getOrDefault(color,0) + node2Colors.get(color));
        }
        colorCount.remove(node2);
        setSize.remove(node2);
    }

    public Integer getSetSize(Integer node){
        if(!roots.contains(node)){
            node = findParent(node);
        }
        return setSize.get(node);
    }

    public Map<Integer, Integer> getColors(Integer node){
        if(!roots.contains(node)){
            node = findParent(node);
        }
        return colorCount.get(node);
    }

    public Set<Integer> getRoots(){
        return  roots;
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}

class Pair<F, S> {
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        InputStream inputStream = null;
//        try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    public void solve(int testNumber, InputReader in, PrintWriter out) {

        Integer socks = in.nextInt();
        Integer days = in.nextInt();
        Integer colors = in.nextInt();
        int[] sockToColor = new int[socks+1];

        for(int i=1; i<=socks; i++){
            sockToColor[i]=in.nextInt();
        }

        boolean[] usedNodes = new boolean[socks+1];
        List<List<Integer>> edges = new ArrayList<>(socks+1);
        for(int i=0; i<=socks; i++){
            edges.add(new ArrayList<>());
        }

        for(int i=0; i<days; i++){
            Integer leftSock = in.nextInt();
            Integer rightSock = in.nextInt();
            usedNodes[leftSock] = Boolean.TRUE;
            usedNodes[rightSock] = Boolean.TRUE;

            edges.get(leftSock).add(rightSock);
            edges.get(rightSock).add(leftSock);
        }

        Integer sum = 0;
        for(int node=1; node<=socks; node++){
            if(!usedNodes[node]){
                continue;
            }

            int [] colorCounts = new int[colors+1];
            Integer componentSize = 0;
            Queue<Integer> q = new ArrayDeque<>();
            q.add(node);

            while(!q.isEmpty()){
                Integer currentNode  = q.poll();
                if(!usedNodes[currentNode]){
                    continue;
                }
                usedNodes[currentNode] = Boolean.FALSE;
//                usedNodes.remove(currentNode);

                componentSize+=1;
                Integer nodeColor = sockToColor[currentNode];
                colorCounts[nodeColor]+=1;

                for(Integer target : edges.get(currentNode)){
                    q.add(target);
                }

            }

            sum+=componentSize - Arrays.stream(colorCounts).max().getAsInt();

        }

        out.println(sum);

    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}

class Pair<F, S> {
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}