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;
const double pi = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int maxn = 5 * 200010;
int n, m, k;
int num[maxn], count1[maxn];
int nump;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    if (temp != num[nump]) {
      nump++;
      num[nump] = temp;
      count1[nump] = 1;
    } else
      count1[nump]++;
  }
  int pre = 0, mid = 0, pro = 0;
  for (int i = 2; i < nump; i++) {
    if (count1[i] > k) {
      mid += (count1[i] / k) * k;
      count1[i] = count1[i] % k;
    }
  }
  int L = 1, R = nump, ans = 0;
  while (num[L] == num[R]) {
    if (L != R && (count1[L] + count1[R]) < k) break;
    if ((count1[L] + count1[R]) >= k) {
      pro += count1[R];
      pre += (count1[L] - (count1[L] + count1[R]) % k);
      count1[L] = (count1[L] + count1[R]) % k;
      R--;
      if (count1[L] == 0) L++;
    }
    if (L == R && count1[L] * m >= k) {
      ans += (count1[L] * m / k) * k;
      break;
    }
  }
  ans += (pre + pro + mid) * m;
  if (num[L] != num[R]) ans -= (pre + pro);
  printf("%d\n", n * m - ans);
  return 0;
}
