10 5 1000000000
1 1 1 2 2 1 2 2 2 2
 5 3 3
1 2 2 1 1
 2 4 1
1 1
 1 1000000000 1000000000
100000
 5 3 2
1 1 2 1 1
 5 2 4
1 2 3 2 1
 1 10 10
1

10000000000
 0
 2
 0
 7
 0
 0

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


public class Main {

    public static boolean debug = false;


    public static StringBuilder makeShort(StringBuilder s , int k)
    {

        for(int i = 0 ; i<s.length()-k;i++)
        {
            char ch = s.charAt(i);
            boolean flag = true;
            for(int j = i+1 ; j<i+k ; j++)
            {
                if( s.charAt(j) != ch)
                {
                    flag = false;
                    break;
                }

            }
            if(flag)
            {
                s.delete(i,i+k);

                i = i-k-1>=0 ?i-k-1:0 ;

            }
        }
        return s;

    }



    static class Klass{
        public int counter;
        public int city;
    }




    public static void main(String[] args) throws FileNotFoundException {
        TimerX.start();


        Scanner scanner = debug ? new Scanner(new File("sample.in")) : new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int m = scanner.nextInt();

        int[] oneTrip = new int[n];

        for(int  i = 0 ; i<n ; i++)
        {
            oneTrip[i] = scanner.nextInt();
        }


        if(k==m)
        {
            int temp = oneTrip[0];
            boolean flag = true;
            for(int i = 0 ; i<oneTrip.length;i++)
            {
                if(oneTrip[i] != temp)
                {
                    flag = false;
                    break;
                }
            }
            if(flag)
            {
                System.out.println("0");
                return;
            }

        }

        Stack<Klass> klassStack = new Stack<Klass>();
        for(int i = 0 ; i<m;i++)
        {
            for(int j = 0;j<oneTrip.length;j++)
            {

                if(klassStack.empty() || klassStack.peek().city!= oneTrip[j])
                {
                    Klass klass = new Klass();
                    klass.counter = 1;
                    klass.city = oneTrip[j];
                    klassStack.push(klass);
                }
                else
                {
                    Klass klass = new Klass();
                    klass.counter = klassStack.peek().counter+1;
                    klass.city = klassStack.peek().city;
                    klassStack.push(klass);
                }

                if(klassStack.size() != 0 &&klassStack.peek().counter == k)
                {   int temp = k;
                    while(temp>0){
                        klassStack.pop();
                        temp--;
                    }
                }
                if(i==0 && j==oneTrip.length-1 && klassStack.size()<oneTrip.length )
                {
                    oneTrip = new int[klassStack.size()];
                    for(int l = 0; l<klassStack.size();l++)
                    {
                        oneTrip[i]=klassStack.get(l).city;
                    }
                }


            }

        }


        System.out.println(klassStack.size());











        TimerX.end();
    }


    static class Utility {
        public static int getDigitSum(int n) {
            int sum = 0;
            while (n > 0) {
                sum += n % 10;
                n /= 10;
            }

            return sum;

        }

        public static void printArr2D(int[][] x) {
            for (int i = 0; i < x.length; i++) {
                for (int j = 0; j < x[i].length; j++) {
                    System.out.print(x[i][j] + " ");
                }
                System.out.println();
            }

        }

        public static  String intArrayToString(int[] x)
        {
            StringBuilder s = new StringBuilder();
            for(int i = 0 ; i<x.length ; i++)
            {
                s.append(String.valueOf(x[i]));
            }
            return s.toString();
        }


    }

    static class TimerX {
        static long startTimer;

        public static void start() {
            startTimer = System.currentTimeMillis();
        }

        public static void end() {
            if (debug) {
                System.out.println("\nExecution time " + timeToString(System.currentTimeMillis() - startTimer));
            }
        }

        public static String timeToString(long diff) {
            long sec = (diff / 1000) % 60;
            long min = (diff / 1000) / 60;

            return min + " minutes and " + sec + " seconds";


        }

    }


}

