#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N], b[N], c[N];
int main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  int top = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (top != -1) {
      if (b[top] == a[i]) {
        if (c[top] + 1 == k)
          top--;
        else
          c[top]++;
      } else {
        b[++top] = a[i];
        c[top] = 1;
      }
    } else {
      b[++top] = a[i];
      c[top] = 1;
    }
  }
  int sum = 0;
  for (int i = 0; i <= top; i++) sum += c[i];
  int cnt2 = 0, x;
  for (x = 0; x < top - x; x++) {
    if (b[x] == b[top - x]) {
      if ((c[x] + c[top - x]) == k)
        cnt2 += k;
      else if (c[x] + c[top - x] > k) {
        cnt2 += k;
        break;
      } else
        break;
    } else
      break;
  }
  if (x + x == top) {
    long long ans = 1ll * c[x] * m % k;
    if (ans) ans += sum - c[x];
    printf("%I64d\n", ans);
  } else
    printf("%I64d\n", 1ll * sum * m - 1ll * cnt2 * (m - 1));
}
