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 n, m, k, a[100010], cnt[100010];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  long long ans = 1LL * n * m;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  int nn = 0;
  for (int i = 1; i <= n; ++i) {
    if (!nn || a[i] != a[nn]) {
      a[++nn] = a[i];
      cnt[nn] = 1;
    } else {
      ++cnt[nn];
      if (cnt[nn] >= k) {
        cnt[nn] -= k;
        ans -= 1LL * k * m;
        if (!cnt[nn]) {
          --nn;
        }
      }
    }
  }
  n = nn;
  int i = 1, j = n;
  while (i < j && a[i] == a[j] && (cnt[i] + cnt[j]) % k == 0) {
    ++i;
    --j;
    ans -= 1LL * (m - 1) * (cnt[i] + cnt[j]);
  }
  if (i == j) {
    printf("%d\n", m % k);
    return 0;
  }
  printf("%I64d\n", ans);
  return 0;
}
