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;
long long n, k, m;
int a[200100], c[200100], kpt, l[200100], r[200100], ct[100100];
inline void Solve(int x, int y) {
  x = l[x];
  y = r[y];
  int cnt = 2;
  while (x && y <= n && a[x] == a[y]) {
    while (a[l[x]] == a[x]) x = l[x], cnt++;
    while (a[r[y]] == r[y]) y = r[y], cnt++;
    cnt %= k;
    if (cnt) break;
    x = l[x];
    y = r[y];
  }
  for (int i = x + 1; i < y; i++) l[i] = x, r[i] = y;
  r[x] = y;
  l[y] = x;
}
int main() {
  scanf("%lld%lld%lld", &n, &k, &m);
  int pre = 1, cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    l[i] = i - 1;
    r[i] = i + 1;
  }
  r[0] = 1;
  l[n + 1] = n;
  for (int i = 1; i <= n; i = r[i]) {
    if (a[i] != a[l[i]]) {
      pre = i;
      ct[i] = 1;
    } else
      ct[i] = ct[i - 1] + 1;
    if (ct[i] == k) {
      Solve(pre, i);
      pre = r[i];
      cnt = 0;
    }
  }
  for (int i = r[0]; i <= n; i = r[i]) c[++kpt] = a[i];
  long long ans = kpt * m;
  if (m == 1) {
    printf("%lld\n", ans);
    return 0;
  }
  if (kpt == 1) {
    printf("%lld\n", m % k);
    return 0;
  }
  int i = 1, j = kpt;
  cnt = 2;
  if (c[i] != c[j]) {
    printf("%lld\n", ans);
    return 0;
  }
  m--;
  while (i < j - 1) {
    while (c[i] == c[i + 1] && i + 1 < j) i++, cnt++;
    while (c[j] == c[j - 1] && i + 1 < j) j--, cnt++;
    ans -= m * (cnt / k) * k;
    cnt %= k;
    if (cnt || i >= j - 1 || c[i + 1] != c[j - 1]) break;
    i++, j--;
    cnt += 2 - (i == j);
  }
  if (i < j - 1) {
    printf("%lld\n", ans);
    return 0;
  }
  cnt = cnt * (m + 1);
  ans -= cnt / k * k;
  cnt %= k;
  if (!cnt) {
    printf("%d\n", 0);
    return 0;
  }
  printf("%lld\n", ans);
  return 0;
}
