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 a[202020], b[202020], g[202020];
int main() {
  int tmp, n, m, k, i, sum, j, h, cnt = 0, n2;
  long long ans;
  scanf("%d%d%d", &n, &k, &m);
  ans = (long long)n * m;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    b[++cnt] = a[i];
    g[cnt] = sum;
    if (a[i] == a[i - 1]) {
      sum++;
      if (sum == k) {
        for (j = 1; j <= k; j++) b[cnt--] = 0;
        sum = g[cnt];
      }
    } else {
      sum = 1;
      g[cnt] = sum;
    }
  }
  h = 1;
  tmp = cnt;
  while (b[cnt] == b[h]) {
    sum = g[cnt];
    for (i = h + 1; i <= n; i++) {
      if (b[i] != b[i - 1]) break;
    }
    if (sum + i >= k) {
      for (i = 1; i <= g[cnt]; i++) b[cnt--] = 0;
      h = k - g[cnt] + h;
    } else
      break;
  }
  n2 = n;
  n = cnt - h + 1;
  for (i = h; i <= cnt; i++) {
    a[i - h + 1] = b[i];
  }
  for (i = 2; i <= n; i++) {
    if (a[i] != a[i - 1]) break;
  }
  if (i <= n) {
    ans = ans - (long long)(n2 - n) * (m - 1);
    ans = ans - (tmp - n);
    printf("%I64d", ans);
    return 0;
  }
  ans = 0;
  ans = ans + (long long)n * m % k;
  if (ans != 0) ans += tmp - n;
  printf("%I64d", ans);
  return 0;
}
