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 = 100005;
int n, k, m, a[N], cnt[N];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  a[0] = -100;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    cnt[i] = a[i] == a[i - 1] ? (cnt[i - 1] + 1) : 1;
    if (cnt[i] == k) i -= k, n -= k;
  }
  if (m == 1) {
    printf("%d", n);
    return 0;
  }
  int L = n + 1, R = 0, pL = n + 1, pR = 0, val;
  while (a[L - 1] == a[R + 1]) {
    L--, R++;
    while (R < L - 1 && a[R + 1] == a[R]) R++;
    while (L > R + 1 && a[L - 1] == a[L]) L--;
    val = R - pR + pL - L - (L == R);
    pR = R, pL = L;
    if (R >= L - 1 || val % k != 0) break;
  }
  if (L == R) {
    long long ans = 1LL * m % k + n - 1;
    if (ans == n - 1) {
      int l = L - 1, r = R + 1;
      long long val = 0;
      while (l > 0 && r <= n && a[l] == a[r]) {
        val += 2;
        while (l > 1 && a[l - 1] == a[l]) l--, val++;
        while (r < n && a[r + 1] == a[r]) r++, val++;
        if (val % k != 0) {
          val = val / k * k;
          break;
        }
        l--, r++;
      }
      ans -= val;
    }
    printf("%I64d", ans);
  } else if (R == L - 1) {
    long long ans = 1LL * (m - 1) * val % k + n;
    if (ans == n) {
      int l = L, r = R;
      long long val = 0;
      while (l > 0 && r <= n && a[l] == a[r]) {
        val += 2;
        while (l > 1 && a[l - 1] == a[l]) l--, val++;
        while (r < n && a[r + 1] == a[r]) r++, val++;
        if (val % k != 0) {
          val = val / k * k;
          break;
        }
        l--, r++;
      }
      ans -= val;
    }
    printf("%I64d", ans);
  } else {
    long long ans = 1LL * (m - 1) * (L - R - 1 + val % k) + n;
    printf("%I64d", ans);
  }
  return 0;
}
