#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 15;
int a[MAXN], b[MAXN], c[MAXN], cnt = 0, sum = 0, n, m, k;
long long ans;
inline int read() {
  int r = 0, z = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') z = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    r = r * 10 + ch - '0';
    ch = getchar();
  }
  return r * z;
}
void work() {
  n = read(), k = read(), m = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] != b[cnt]) {
      b[++cnt] = a[i];
      c[cnt] = 1;
    } else {
      c[cnt]++;
      if (c[cnt] == k) cnt--;
    }
  }
  if (!cnt) {
    puts("0");
    return;
  }
  for (int i = 1; i <= cnt; i++) sum += c[i];
  int i, cnt1 = 0;
  for (i = 1; i < cnt + 1 - i; i++) {
    if (b[i] == b[cnt + 1 - i] && c[i] + c[cnt + 1 - i] == k)
      cnt1 += k;
    else
      break;
  }
  if (i < cnt + 1 - i) {
    if (b[i] == b[cnt + 1 - i] && c[i] + c[cnt + 1 - i] > k) cnt1 += k;
    ans = 1ll * sum * m - 1ll * cnt1 * (m - 1);
  } else {
    ans = 1ll * c[i] * m % k;
    if (ans) ans += 1ll * (sum - c[i]);
  }
  printf("%I64d\n", ans);
}
int main() {
  work();
  return 0;
}
