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[2 * N], c[2 * N], b1[2 * N], c1[2 * N];
int main() {
  int n, k, m, flag = -1;
  scanf("%d%d%d", &n, &k, &m);
  int cnt1 = n, top = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (flag == -1)
      flag = a[i];
    else if (flag != a[i])
      flag = 0;
    if (top != -1) {
      if (b[top] == a[i]) {
        if (c[top] + 1 == k) {
          cnt1 -= k;
          top--;
        } else
          c[top]++;
      } else {
        b[++top] = a[i];
        c[top]++;
      }
    } else {
      b[++top] = a[i];
      c[top]++;
    }
  }
  memcpy(b1, b, sizeof(b));
  memcpy(c1, c, sizeof(c));
  int cnt2 = 0, top1 = top;
  for (int i = 0; i <= top1; i++) {
    if (top != -1) {
      if (b[top] == b1[i]) {
        if (c[top] + c1[i] >= k) {
          cnt2 += k;
          if ((c[top] + c1[i]) % k == 0)
            top--;
          else
            break;
        }
      } else
        break;
    }
  }
  if (n == 1) flag = 1;
  if (!flag)
    printf("%I64d\n", -(1ll * m - 1) * cnt2 + m * cnt1);
  else
    printf("%d\n", m % k);
}
