#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 100005;
int a[maxn], f[maxn], t[maxn], top;
int main() {
  long long n, m, k, ans = 0;
  scanf("%lld%lld%lld", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  top = 0;
  for (int i = 1; i <= n; i++) {
    t[++top] = a[i];
    if (top == 1 || t[top] != t[top - 1])
      f[top] = 1;
    else
      f[top] = f[top - 1] + 1;
    if (f[top] == k) top -= k;
  }
  int l = 1, r = top;
  while (l < r && t[l] == t[r]) {
    int L = l, R = r, cnt = 0;
    while (L < R && t[L] == t[l] && cnt < k) {
      ++cnt;
      ++L;
    }
    while (L < R && t[r] == t[R] && cnt < k) {
      ++cnt;
      --R;
    }
    if (cnt == k) {
      ans += k;
      l = L;
      r = R;
    } else
      break;
  }
  int flag = 1;
  for (int i = l + 1; i <= r; i++) {
    if (t[i] != t[i - 1]) {
      flag = 0;
      break;
    }
  }
  if (flag) {
    if ((long long)(r - l + 1) * m % k != 0)
      printf("%lld\n", (long long)(r - l + 1) * m % k + ans);
    else
      printf("0\n");
  } else
    printf("%lld\n", (long long)(r - l + 1) * m + ans);
}
