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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Swatantra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int m = in.nextInt();
            long ans = 1l * m * n;
            //out.println("ans="+ans);
            int i;
            int count = 0;
            int sta[] = new int[n];
            int stb[] = new int[n];
            for (i = 0; i < n; i++) {
                int x = in.nextInt();
                if (count > 0 && sta[count - 1] == x) {
                    stb[count]++;
                    if (stb[count] == k) {
                        ans -= m * k;
                        //out.println("In 1 ans="+ans);
                        count--;
                    }
                } else {
                    sta[count] = x;
                    stb[count] = 1;
                    count++;
                }
            }
            int l = 0;
            int r = count - 1;
            while (r > l && sta[r] == sta[l] && (stb[l] + stb[r] >= k)) {
                int total = stb[l] + stb[r];
                ans -= (m - 1) * (total / k) * k;
                //out.println("In 2 ans="+ans);
                if (total % k == 0) {
                    l++;
                    r--;
                } else
                    break;
            }
            if (l == r) {
                int total = stb[l] * m;
                ans -= (total / k) * k;
                //out.println("In 3 ans="+ans);
                if (total % k == 0) {
                    while (l > 0 && r < count && sta[l] == sta[r] && (stb[l] + stb[r] >= k)) {
                        int total2 = stb[l] + stb[r];
                        ans -= (total2 / k) * k;
                        //out.println("In 4 ans="+ans);
                        if (total % k == 0) {
                            l--;
                            r++;
                        } else
                            break;

                    }
                }
            }
            out.println(ans);
        }

    }
}

