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

public class D {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long m = sc.nextLong();
        
        LinkedList<CF> begin = new LinkedList<>();
        LinkedList<CF> end = new LinkedList<>();
        LinkedList<CF> middle = new LinkedList<>();
        
        for (int i = 0; i < n; i++) {
            long c = sc.nextLong();
            if (middle.size() > 0 && middle.get(middle.size()-1).c == c) {
                middle.get(middle.size()-1).f++;
                if (middle.get(middle.size()-1).f%k == 0) {
                    middle.remove(middle.size()-1);
                }
            } else {
                CF cf = new CF();
                cf.c = c; cf.f = 1;
                middle.add(cf);
            }
        }
        
        while (true) {
            if (middle.size() <= 1) break;
            CF mf = middle.getFirst(); CF ml = middle.getLast();
            if (mf.c == ml.c && mf.f+ml.f >= k) {
                middle.removeLast();
                end.addFirst(ml);
                mf.f -= k-ml.f;
                if (mf.f == 0) middle.removeFirst();
                CF bl = new CF(); bl.c = mf.c; bl.f = k-ml.f;
                begin.addLast(bl);
            } else {
                break;
            }
        }
        
        if (middle.size() == 1) {
            CF mf = middle.getFirst();
            m *= mf.f; mf.f = 1;
            m %= k;
        } else if (middle.size() == 0) {
            m = 0;
        }
        
        if (m == 0 && !begin.isEmpty() && !end.isEmpty()) {
            CF bl = begin.getLast();
            CF ef = end.getFirst();
            while (bl.c == ef.c && bl.f + ef.f >= k) {
                end.removeFirst();
                bl.f -= k-ef.f;
                if (bl.f == 0) {
                    begin.removeLast();
                }
                if (begin.size() == 0 || end.size() == 0) break;
                bl = begin.getLast();
                ef = end.getFirst();
            }
        }
        
        long size = 0;
        for (CF cf : begin) {
            size += cf.f;
        }
        for (CF cf : middle) {
            size += m*cf.f;
        }
        for (CF cf : end) {
            size += cf.f;
        }
        System.out.println(size);
    }
    
}

class CF {
    long c;
    long f;
}