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 MAXN = 1e5 + 10;
long long n, m, k, len, res;
long long a[MAXN], seq[MAXN], cnt[MAXN];
bool singleColor;
int main() {
  scanf("%lld%lld%lld", &n, &k, &m);
  for (long long i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  singleColor = true;
  for (long long i = 2; i <= n; ++i)
    if (a[i] != a[1]) {
      singleColor = false;
      break;
    }
  if (singleColor) {
    res = n * m % k;
    printf("%lld\n", res);
    return 0;
  }
  for (long long i = 1; i <= n; ++i) {
    seq[++len] = a[i];
    if (seq[len] == seq[len - 1])
      cnt[len] = cnt[len - 1] + 1;
    else
      cnt[len] = 1;
    if (cnt[len] == k) len -= k;
  }
  singleColor = true;
  for (long long i = 2; i <= len; ++i)
    if (seq[i] != seq[1]) {
      singleColor = false;
      break;
    }
  if (singleColor) {
    res = len * m % k;
    printf("%lld\n", res);
    return 0;
  }
  long long l, r, ct, L = 1, R = len, sum = 0;
  while (L < R) {
    l = L;
    r = R;
    ct = 0;
    while (l < r && seq[l] == seq[L] && ct < k) {
      ++ct;
      ++l;
    }
    while (l < r && seq[r] == seq[L] && ct < k) {
      ++ct;
      --r;
    }
    if (ct == k) {
      L = l;
      R = r;
      sum += k;
    } else
      break;
  }
  singleColor = true;
  for (int i = L + 1; i <= R; ++i)
    if (seq[i] != seq[L]) {
      singleColor = false;
      break;
    }
  if (singleColor) {
    res = (R - L + 1) * m % k;
    if (res) res += sum;
    printf("%lld\n", res);
    return 0;
  }
  res = (R - L + 1) * m + sum;
  printf("%lld\n", res);
  return 0;
}
