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;
int a[(200005)], st[(200005)], n, m, k, top;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  if (!k) {
    printf("%d", 0);
    return 0;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int len = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1])
      len = 1;
    else
      ++len;
    st[++top] = a[i];
    if (len == k) top -= k, len = 0;
  }
  memset(a, 0, sizeof(a));
  n = top;
  for (int i = 1; i <= n; i++) a[i] = st[i];
  int h = 1, t = n;
  long long ans = 0;
  while (h < t) {
    if (a[h] != a[t]) break;
    int cnt = ((k) < (2) ? (k) : (2));
    while (a[h + 1] == a[h] && h < t && cnt < k) h++, cnt++;
    while (a[t - 1] == a[t] && h < t && cnt < k) t--, cnt++;
    if (cnt == k)
      ans += k, h++, t--;
    else
      break;
  }
  bool van = 1;
  for (int i = h + 1; i <= t; i++)
    if (a[i] != a[i - 1]) {
      van = 0;
      break;
    }
  if (van)
    cout << (long long)(t - h + 1) * m % k
        ? (long long)(t - h + 1) * m % k + ans
        : 0;
  else
    cout << (long long)(t - h + 1) * m + ans;
}
