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.util.*;
import java.math.*;

public class main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;

    public static void main(String[] args) throws Exception{
        st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        int[] A = new int[N];
        st = new StringTokenizer(br.readLine());
        for(int i = 0; i < N; i++){
            A[i] = Integer.parseInt(st.nextToken());
        }

        Stack<Pair> S = new Stack<Pair>();
        for(int i = 0; i < N; i++){
            if(S.size() == 0 || S.peek().x != A[i]){
                S.push(new Pair(A[i], 1));
            } else{
                Pair p = S.peek();
                p.y += 1;
                if(p.y == K){
                    S.pop();
                }
            }
        }
        long ans = (long)S.size() * M;
        ArrayList<Pair> order = new ArrayList<Pair>(S);
        int first = 0;
        int last = order.size()-1;
        while(first < last){
            Pair p1 = order.get(first);
            Pair p2 = order.get(last);

            if(p1.x == p2.x){
                if(p1.y + p2.y >= K){
                    ans -= (long)K * (M - 1);
                    if(p1.y + p2.y > K) break;
                }
            } else{
                break;
            }
            first++;
            last--;
        }

        if(first == last){
            long rem = (long)order.get(first).y * M;
            ans = M % K;
        }

        pw.print(ans + "\n");

        pw.close(); 
        br.close();
    }
}

class Pair{
    public int x, y;

    Pair(int _x, int _y){
        x = _x;
        y = _y;
    }
}

class Point implements Comparable<Point>{
    public double x, y;

    Point(double x, double y){
        this.x = x;
        this.y = y;
    }

    public int compareTo(Point p){
        if(x != p.x) return x < p.x ? -1 : 1;
        else if(y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
}