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 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));
}
