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;
struct node {
  int x, cnt;
} b[100010];
int main() {
  long long n, m, k;
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  int x = -1, cnt = 0, tot = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    if (a != x)
      b[tot++] = {x, cnt}, cnt = 1, x = a;
    else {
      ++cnt;
      if (cnt == k) cnt = 0;
    }
  }
  if (cnt) b[tot++] = {x, cnt};
  int i = 1, j = tot - 1;
  for (; i < j; ++i, --j)
    if (b[i].x != b[j].x || b[i].cnt + b[j].cnt != k) break;
  long long ans;
  if (i > j)
    ans = (m & 1) ? n : 0;
  else if (i == j)
    ans = 1LL * b[i].cnt * m % k;
  else {
    int num = 0;
    for (int k = i; k <= j; ++k) num += b[k].cnt;
    ans = 1LL * num * m + (i - 1) * k;
  }
  printf("%I64d\n", ans);
  return 0;
}
