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 mainpackage;

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String... args) throws Exception {
		
		out = new PrintWriter(System.out);
		new Main().solve();
		out.close();
	}

	private static PrintWriter out;
	
	private BufferedReader reader;
	private StringTokenizer st;
	
	private int n, m, k;
	private int[] id, cnt;
	private int size;
	
	private void solve() throws Exception {
		
		reader = new BufferedReader(new InputStreamReader(System.in));
		
		st = new StringTokenizer(reader.readLine());
		n = Integer.parseInt(st.nextToken());
		k = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());
		
		
		id = new int[n];
		cnt = new int[n];
		size = 0;
		
		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; ++i) {
			int curId = Integer.parseInt(st.nextToken());
			
			if (size == 0) {
				id[size] = curId;
				cnt[size++] = 1;
				continue;
			}
			
			if (id[size - 1] == curId) {
				cnt[size - 1]++;
				continue;
			}
			
			cnt[size - 1] %= k;
			if (cnt[size - 1] == 0) {
				
				if (size == 0 || id[size - 1] != curId) {
					id[size] = curId;
					cnt[size++] = 1;
					continue;
				}
				
				cnt[size - 1]++;
			}
		}
		
		cnt[size - 1] %= k;
		if (cnt[size - 1] == 0) {
			size--;
		}
		
		reader.close();
		
		
		long sum = 0L;
		for (int i = 0; i < size; ++i) {
			sum += (long)cnt[i];
		}

		if (m == 1) {
			out.println(sum);
			return;
		}
		
		sum *= (long)m;
		
		
		int p1 = 0, p2 = size - 1;
		while(p2 > p1 && id[p1] == id[p2]) {
			
			if ((cnt[p1] + cnt[p2]) % k == 0) {
				sum -= (long)(cnt[p1] + cnt[p2]) * (m - 1);
				p1++;
				p2--;
			} else {
				
				long tmp = (cnt[p1] + cnt[p2]) - (cnt[p1] + cnt[p2])%k;
				sum -= tmp * (m - 1);
				p2--;
			}
		}
		
		if (p1 == p2) {
			
			while(p1 >= 0) {
				long tmp = (p1 == p2) ? (long)cnt[p1] * m : (long)cnt[p1] * 2;
				if ((tmp % k) > 0) {
					sum -= (tmp - tmp%k);
					break;
				}
				
				sum -= tmp;
				p1--;
			}
		}
		
		out.println(sum);
	}
}
