#include <bits/stdc++.h>
using namespace std;
int n, m, k, s[100009];
int a[100009], b[100009], t = 0;
long long ans = 0;
void init() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", s + i);
  for (int i = 1; i <= n; ++i) {
    if (s[i] != a[t])
      a[++t] = s[i], b[t] = 1;
    else {
      ++b[t];
      if (b[t] == k) ans += k, --t;
    }
  }
  ans *= m;
}
int main() {
  init();
  int l = 1, r = t;
  while (l <= r) {
    if (a[l] != a[r]) break;
    if (l == r) {
      ans += 1ll * b[l] * m / k * k;
      break;
    }
    if (b[l] + b[r] >= k) {
      ans += 1ll * k * (m - 1);
      if (b[l] + b[r] == k)
        ++l, --r;
      else
        break;
    } else
      break;
  }
  if (l == r && 1ll * b[l] * m % k == 0) ans = 1ll * n * m;
  printf("%I64d", 1ll * n * m - ans);
  return 0;
}
