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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * @author Don Li
 */
public class TeamsFormation {
    
    void solve() {
        int n = in.nextInt(), k = in.nextInt(), m = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();
        
        Deque<int[]> qu = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            if (!qu.isEmpty() && qu.getLast()[0] == a[i]) {
                if (++qu.getLast()[1] == k) qu.removeLast();
            } else {
                qu.offerLast(new int[]{a[i], 1});
            }
        }
        
        n = qu.size();
        List<int[]> pairs = new ArrayList<>(qu);
        int len = 0;
        for (int i = 0; i < n; i++) len += pairs.get(i)[1];
        
        int p = 0;
        for (int i = 0; i < n; i++) {
            int[] u = pairs.get(i), v = pairs.get(n - 1 - i);
            if (u[0] == v[0] && u[1] + v[1] == k) {
                p++;
            } else {
                break;
            }
        }
        
        if (p >= (n + 1) / 2) {
            out.println(m % 2 == 0 ? 0 : len);
            return;
        }
        
        if (n % 2 == 1) {
            if (p == n / 2) {
                long center = (long) pairs.get(p)[1] * m;
                if (center % k == 0) {
                    out.println(0);
                } else {
                    out.println(len - pairs.get(p)[1] + center % k);
                }
            } else {
                long ans = (long) len * m, del = 0;
                for (int i = 0; i < p; i++) del += pairs.get(i)[1];
                for (int i = n - p; i < n; i++) del += pairs.get(i)[1];
                int[] u = pairs.get(p), v = pairs.get(n - 1 - p);
                if (u[0] == v[0] && u[1] + v[1] >= k) del += k;
                out.println(ans - (m - 1) * del);
            }
        } else {
            long ans = (long) len * m, del = 0;
            for (int i = 0; i < p; i++) del += pairs.get(i)[1];
            for (int i = n - p; i < n; i++) del += pairs.get(i)[1];
            int[] u = pairs.get(p), v = pairs.get(n - 1 - p);
            if (u[0] == v[0] && u[1] + v[1] >= k) del += k;
            out.println(ans - (m - 1) * del);
        }
    }
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new TeamsFormation().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}
