#include <bits/stdc++.h>
using namespace std;
int l, r, n, k, m, now, tot, all;
int a[200000], s[200000];
struct fk {
  int num, val;
  bool operator==(const fk &b) { return (num + b.num == k && val == b.val); }
} tp[200000];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  all = 0;
  tp[0].num = tp[0].val = -1;
  for (int i = 1; i <= n; ++i) {
    if (a[i] == tp[all].val) {
      ++tp[all].num;
      if (tp[all].num == k) --all;
    } else {
      tp[++all].val = a[i];
      tp[all].num = 1;
    }
  }
  n = 0;
  for (int i = 1; i <= all; ++i) n += tp[i].num;
  int p = 0;
  for (int i = 1; i <= all; ++i) {
    if (tp[i] == tp[all - i + 1])
      p = i;
    else
      break;
  }
  long long ans = 0, temp;
  if (p >= (all + 1) / 2) {
    if (m % 2)
      for (int i = 1; i <= all; ++i) ans += tp[i].num;
  } else if (all % 2 == 1 && p == all / 2) {
    temp = m % k * tp[p + 1].num % k;
    if (temp % k == 0)
      ans = 0;
    else {
      ans = (long long)p * k;
      ans = ans + temp;
    }
  } else {
    ans = (long long)m * n;
    for (int i = 1; i <= p; ++i) ans -= (long long)p * k * (m - 1);
    ans -= (tp[p + 1].val == tp[all - p].val &&
            tp[p + 1].num + tp[all - p].num >= k)
               ? (long long)k * (m - 1)
               : 0;
  }
  printf("%I64d\n", ans);
  return 0;
}
