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 long long maxn = (long long)1e5 + 100;
long long n, k, m, a[maxn], sta[maxn], cnt[maxn];
long long top;
int main() {
  scanf("%lld%lld%lld", &n, &k, &m);
  for (long long i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  bool single = true;
  for (long long i = 1; i < n; ++i)
    if (a[i] != a[i + 1]) {
      single = false;
      break;
    }
  if (single)
    printf("%lld\n", n * m % k);
  else {
    top = 0;
    for (long long i = 1; i <= n; ++i) {
      sta[++top] = a[i];
      if (top == 1 || sta[top] != sta[top - 1])
        cnt[top] = 1;
      else
        cnt[top] = cnt[top - 1] + 1;
      if (cnt[top] >= k) top -= k;
    }
    long long L = 1, R = top, eli = 0;
    while (L < R && sta[L] == sta[R]) {
      long long l = L, r = R, tmp = 0;
      while (l < r && sta[l] == sta[R] && tmp < k) {
        ++l;
        ++tmp;
      }
      while (l < r && sta[r] == sta[L] && tmp < k) {
        --r;
        ++tmp;
      }
      if (tmp == k) {
        L = l, R = r;
        eli += k;
      } else
        break;
    }
    single = true;
    for (long long i = L; i < R; ++i)
      if (sta[i] != sta[i + 1]) {
        single = false;
        break;
      }
    if (single) {
      long long tmp = (R - L + 1) * m % k;
      printf("%lld\n", tmp + (tmp > 0 ? eli : 0));
    } else {
      printf("%lld\n", (R - L + 1) * m + eli);
    }
  }
}
