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, i, j, L, R, A[100000], B[100000];
long long K, M, H;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> K >> M;
  for (i = 0; i < N; i++) {
    cin >> A[L];
    if (L > 0 && A[L] == A[L - 1]) {
      B[L] = B[L - 1] + 1;
      if (B[L] == K) {
        L -= K;
      }
    } else {
      B[L] = 1;
    }
    L++;
  }
  N = L;
  L = 0;
  R = N - 1;
  while (A[L] == A[R]) {
    for (i = L; i < R && A[i] == A[L]; i++) {
    }
    for (j = R; j > L && A[j] == A[R]; j--) {
    }
    if (i == R) {
      if ((M * (R - L + 1)) % K == 0) {
        cout << 0 << '\n';
      } else {
        cout << (N - R + L - 1) + (M * (R - L + 1)) % K << '\n';
      }
      return 0;
    }
    if (R - j + i - L == K) {
      R = j;
      L = i;
    } else {
      if (R - j + i - L > K) {
        R -= K;
      }
      break;
    }
  }
  cout << N + (M - 1) * (R - L + 1) << '\n';
}
