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;
long long n, k, m;
int a[200100], c[200100], kpt, l[200100], r[200100], ct[100100], b[100100];
int main() {
  scanf("%lld%lld%lld", &n, &k, &m);
  int pre = 1, cnt = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1, j = 1; i <= n; i = j) {
    for (; j <= n && a[i] == a[j]; j++)
      ;
    if ((j - i) % k) {
      c[cnt] = a[i], b[cnt++] = (j - i) % k;
      if (cnt > 1 && c[cnt - 1] == c[cnt - 2]) {
        cnt--;
        (b[cnt - 1] += b[cnt]) %= k;
        if (!b[cnt - 1]) --cnt;
      }
    }
  }
  kpt = cnt - 1;
  long long ans = kpt * m;
  if (m == 1) {
    printf("%lld\n", ans);
    return 0;
  }
  if (kpt == 1) {
    printf("%lld\n", m % k);
    return 0;
  }
  int i = 1, j = kpt;
  cnt = 2;
  if (c[i] != c[j]) {
    printf("%lld\n", ans);
    return 0;
  }
  m--;
  while (i < j - 1) {
    while (c[i] == c[i + 1] && i + 1 < j) i++, cnt++;
    while (c[j] == c[j - 1] && i + 1 < j) j--, cnt++;
    ans -= m * (cnt / k) * k;
    cnt %= k;
    if (cnt || i >= j - 1 || c[i + 1] != c[j - 1]) break;
    i++, j--;
    cnt += 2 - (i == j);
  }
  if (i < j - 1) {
    printf("%lld\n", ans);
    return 0;
  }
  cnt = cnt * (m + 1);
  ans -= cnt / k * k;
  cnt %= k;
  if (!cnt) {
    printf("%d\n", 0);
    return 0;
  }
  printf("%lld\n", ans);
  return 0;
}
