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 int N = 100000 + 10;
int n, m, k;
int a[N], S[N], cnt[N], top;
int main() {
  bool signal_color = true;
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 2; i <= n; ++i) {
    if (a[i] != a[i - 1]) {
      signal_color = false;
      break;
    }
  }
  if (signal_color) {
    return 0 * printf("%lld\n", 1ll * n * m % k);
  }
  for (int i = 1; i <= n; ++i) {
    S[++top] = a[i];
    if (top > 1 && S[top] == S[top - 1])
      cnt[top] = cnt[top - 1] + 1;
    else
      cnt[top] = 1;
    if (cnt[top] >= k) top -= k;
  }
  int L = 1, R = top;
  long long t = 0;
  while (S[L] == S[R] && L < R) {
    int l = L, r = R, cnt = 0;
    while (S[l] == S[L] && cnt < k) cnt++, l++;
    while (S[r] == S[L] && cnt < k) cnt++, r--;
    if (cnt == k) {
      L = l, R = r, t += k;
    } else
      break;
  }
  signal_color = true;
  for (int i = L; i < R; ++i) {
    if (S[i] != S[i + 1]) {
      signal_color = false;
      break;
    }
  }
  if (signal_color) {
    long long mid = 1ll * (R - L + 1) * m % k;
    if (mid)
      printf("%lld\n", mid + t);
    else
      printf("0\n");
  } else {
    printf("%lld\n", 1ll * (R - L + 1) * m + t);
  }
  return 0;
}
