#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  static int ch;
  static bool flag;
  for (flag = 0, ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    flag |= ch == '-';
  for (x = 0; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - 48;
  x = flag ? -x : x;
}
int N, K, M, cnt;
int A[500005], B[500005];
long long Ans, Sum;
inline int dy() {
  read(N), read(K), read(M);
  for (register int i = 1; i <= N; ++i) read(A[i]);
  for (register int i = 1; i <= N; ++i)
    if (A[cnt] != A[i])
      A[++cnt] = A[i], B[cnt] = 1;
    else {
      B[cnt]++;
      if (B[cnt] == K) cnt--;
    }
  if (!cnt) putchar('0'), exit(0);
  for (register int i = 1; i <= cnt; ++i) Sum += B[i];
  int len = 0, pos;
  for (pos = 1; pos <= cnt - pos; ++pos)
    if (A[pos] == A[cnt + 1 - pos] && B[pos] + B[cnt + 1 - pos] == K)
      len += K;
    else
      break;
  if (pos < cnt + 1 - pos) {
    if (A[pos] == A[cnt + 1 - pos] && B[pos] + B[cnt + 1 - pos] >= K) len += K;
    Ans = 1ll * Sum * M - 1ll * len * (M - 1);
  } else {
    Ans = 1ll * B[pos] * M % K;
    if (Ans) Ans += Sum - B[pos];
  }
  printf("%lld\n", Ans);
  return 0;
}
int QAQ = dy();
int main() { ; }
