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

//package com.company;
import java.io.*;
import java.math.BigInteger;
import java.text.CollationElementIterator;
import java.util.*;

public class Main
{
    static class group{
        int idx;
        int number;
        group(int a){idx = a;number = 1;}
        group copy(){
            group cp = new group(idx);
            cp.number = number;
            return cp;
        }
    }

    static group[] g;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int k = sc.nextInt(); int m = sc.nextInt();
        Deque<group> st = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            int c = sc.nextInt();
            if (st.size() == 0 || st.peek().idx != c){
                st.push(new group(c));
            } else {
                st.peek().number += 1;
            }
            if (st.peek().number == k){
                st.pop();
            }
        }
        Iterator<group> iter = st.iterator();
        long sum = 0;
        while (iter.hasNext()){
            group g = iter.next().copy();
            sum += g.number;
        }
        while (st.size() >= 2){
            group fr = st.peekFirst();
            group la = st.peekLast();
            if (fr.idx == la.idx){
                int re = (fr.number + la.number)%k;
                if (re != 0){
                    fr.number = re;
                    st.pollLast();
                    break;
                } else {
                    st.pollLast();
                    st.pollFirst();
                }
            } else {
                break;
            }
        }
        int cur_sum = 0;

        for (group g : st) {
            cur_sum += g.number;
        }
        long delo = (sum - cur_sum);
        if (st.size() == 0){
            System.out.println(m %2 == 0 ? 0 : cur_sum);
        }else if (st.size() == 1){
            if (st.peekLast().number % k == 0){
                System.out.println(m%2 == 0 ? 0 : sum);
            } else {
                if (st.peekLast().number * (long) m % k == 0){
                    System.out.println(0);
                } else {
                    System.out.println(((long) (m) * (long) cur_sum) % k + delo);
                }
            }
        } else {
            System.out.println((long)sum*(long)m - delo*(long)(m-1));
        }

    }
}