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;
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);
  a[n + 1] = 0;
  all = 1;
  now = a[1];
  tp[1].val = a[1];
  tp[1].num = 1;
  tp[0].num = tp[0].val = -1;
  for (int i = 2; 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, temp2 = 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 (p >= 1) {
      if (tp[p].val == tp[p + 1].val) temp2 += tp[p].num;
      ans += tp[p].num;
    }
    if (p + 2 <= all) {
      if (tp[p + 2].val == tp[p + 1].val) temp2 += tp[p + 2].num;
      ans += tp[p + 2].num;
    }
    if ((temp + temp2) % k == 0)
      ans = 0;
    else {
      ans = ans + temp - (temp + temp2) / k * k;
    }
  } else {
    ans = (long long)m * n;
    for (int i = 1; i <= p; ++i) ans -= (long long)tp[i].num * 2 * (m - 1);
  }
  printf("%I64d\n", ans);
  return 0;
}
