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>
long long val[111111], cnt[111111], sum, ans, idx;
int main() {
  long long n, k, m, x;
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &x);
    if (x == val[idx]) {
      if (++cnt[idx] == k) idx--;
    } else {
      val[++idx] = x;
      cnt[idx] = 1;
    }
  }
  for (int i = 1; i <= idx; i++) sum += cnt[i];
  long long head = 1, tail = idx;
  while (head < tail && val[head] == val[tail]) {
    if ((cnt[head] + cnt[tail]) % k == 0) {
      head++, tail--;
    } else {
      cnt[head] = (cnt[head] + cnt[tail]) % k;
      cnt[tail] = 0;
      tail--;
    }
  }
  if (head < tail) {
    for (int i = head; i <= tail; i++) {
      ans += cnt[i];
    }
    ans = sum + ans * (m - 1);
  } else {
    if (cnt[head] * m % k == 0)
      ans = 0;
    else
      ans = sum - cnt[head] + cnt[head] * m % k;
  }
  printf("%I64d\n", ans);
  return 0;
}
