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