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 Cnt[100005], Num[100005];
int main() {
  int n, k, m, a;
  scanf("%d %d %d", &n, &k, &m);
  int len = 0;
  while (n--) {
    scanf("%d", &a);
    if (len == 0 || Num[len] != a) {
      Num[++len] = a;
      Cnt[len] = 1;
    } else
      Cnt[len]++;
    if (Cnt[len] == k) len--;
  }
  int head = 1, tail = len;
  long long S1 = 0, S2 = 0;
  for (int i = 1; i <= len; i++) S1 += Cnt[i];
  while (head < tail && Num[head] == Num[tail]) {
    if ((Cnt[head] + Cnt[tail]) % k == 0) {
      head++;
      tail--;
    } else {
      Cnt[head] = (Cnt[head] + Cnt[tail]) % k;
      tail--;
      break;
    }
  }
  for (int i = head; i <= tail; i++) S2 += Cnt[i];
  long long ans = 0;
  if (head < tail)
    ans = S1 + S2 * (m - 1);
  else if ((Cnt[head] * m) % k != 0)
    ans = S1 + (Cnt[head] * m) % k - Cnt[head];
  printf("%lld\n", ans);
}
