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

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int n, m, k;
int a[maxn], S[maxn], cnt[maxn], top;
int main() {
  bool single_color = true;
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 1; i < n; i++)
    if (a[i] != a[i - 1]) {
      single_color = false;
      break;
    }
  if (single_color) {
    printf("%I64d\n", (long long)n * m % k);
    return 0;
  }
  for (int i = 0; i < n; i++) {
    S[++top] = a[i];
    if (top > 1 && S[top] == S[top - 1])
      cnt[top] = cnt[top - 1] + 1;
    else
      cnt[top] = 1;
    if (cnt[top] >= k) top -= k;
  }
  int L = 1, R = top;
  long long t = 0;
  while (S[L] == S[R] && L < R) {
    int l = L, r = R, cnt = 0;
    while (S[l] == S[L] && l < r && cnt < k) {
      cnt++;
      l++;
    }
    while (S[r] == S[L] && l < r && cnt < k) {
      cnt++;
      r--;
    }
    if (cnt == k) {
      L = l;
      R = r;
      t += k;
    } else
      break;
  }
  single_color = true;
  for (int i = L; i < R; i++)
    if (S[i] != S[i + 1]) {
      single_color = false;
      break;
    }
  if (single_color) {
    long long mid = (long long)(R - L + 1) * m % k;
    if (mid)
      printf("%I64d\n", mid + t);
    else
      printf("0\n");
  } else {
    printf("%I64d\n", (long long)(R - L + 1) * m + t);
  }
  return 0;
}
