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 maxn = 100100;
int a[maxn];
int s[maxn], top = 0;
int cnt[maxn];
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int single_color = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i + 1]) {
      single_color = 0;
      break;
    }
  }
  if (single_color) {
    printf("%lld\n", (long long)n * m % k);
    return 0;
  }
  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;
    int cnt = 0;
    while (s[l] == s[L] && cnt < k && l < r) {
      cnt++, l++;
    }
    while (s[r] == s[L] && cnt < k && l < r) {
      cnt++, r--;
    }
    if (cnt == k) {
      L = l;
      R = r;
      t += k;
    } else
      break;
  }
  single_color = 1;
  for (int i = L; i < R; i++) {
    if (s[i] != s[i + 1]) {
      single_color = 0;
      break;
    }
  }
  if (single_color) {
    long long tmp = (long long)(R - L + 1) * m % k;
    if (tmp == 0)
      printf("0\n");
    else {
      printf("%lld\n", tmp + t);
    }
  } else {
    printf("%lld\n", (long long)(R - L + 1) * m + t);
  }
  return 0;
}
