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;
int n, m, k;
const int maxn = 2e5 + 10;
int a[maxn];
int L, R;
int S[maxn], top;
int cnt[maxn];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  bool flag = 1;
  for (int i = 2; i <= n; i++)
    if (a[i] != a[i - 1]) {
      flag = 0;
      break;
    }
  if (flag) {
    return printf("%d\n", 1ll * n * m % k), 0;
  }
  top = 0;
  for (int i = 1; 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;
  }
  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;
  }
  flag = 1;
  for (int i = L; i < R; i++)
    if (S[i] != S[i + 1]) {
      flag = 0;
      break;
    }
  if (flag) {
    int mid = 1ll * (R - L + 1) * m % k;
    if (mid)
      printf("%d\n", (mid + t));
    else
      printf("%d\n", 0);
  } else
    printf("%d\n", (1ll * (R - L + 1) * m + t));
  return 0;
}
