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 INF = 0x3f2f1f0f;
const long long LINF = 1ll * INF * INF;
const int MAX_N = 1e5 + 100;
int N, K, M, Temp[MAX_N], Nr[MAX_N];
int main() {
  cin >> N >> K >> M;
  for (int i = 0; i < N; i++) scanf("%d", &Temp[i]);
  deque<pair<int, int> > St;
  for (int i = 0; i < N; i++) {
    int v = Temp[i];
    if (St.empty() || St.back().first != v)
      St.push_back(pair<int, int>(v, 1));
    else {
      int a, b;
      tie(a, b) = St.back();
      St.pop_back();
      if (b + 1 == K) {
        continue;
      }
      St.push_back(pair<int, int>(a, b + 1));
    }
  }
  N = 0;
  for (pair<int, int> &p : St) {
    int v, c;
    tie(v, c) = p;
    for (int i = 0; i < c; i++) Nr[N++] = v;
  }
  bool allSame = true;
  for (int i = 0; i < N; i++) {
    allSame &= (Nr[i] == Nr[0]);
  }
  if (allSame) {
    long long ans = 1ll * N * M % K;
    printf("%lld\n", ans);
    return 0;
  }
  stack<pair<int, int> > S;
  long long goOn = 0;
  int r = 0;
  for (int i = 0; i < 2 * N; i++) {
    int v = Nr[i % N];
    if (S.empty() || S.top().first != v)
      S.push(pair<int, int>(v, 1));
    else {
      int a, b;
      tie(a, b) = S.top();
      S.pop();
      if (b + 1 == K) {
        goOn += K;
        r = i + 1;
        continue;
      }
      S.push(pair<int, int>(a, b + 1));
    }
  }
  if (goOn <= N)
    printf("%lld\n", 1ll * N * M - goOn * (M - 1));
  else if (goOn == 2 * N)
    printf("%d\n", N * (M % 2));
  else {
    int l = r - goOn;
    int b = r % N - l;
    int ca = 0;
    if ((2 * b) % K > 0) ca = K - (2 * b) % K;
    int div = M / 2;
    long long ans = 1ll * ca * (M - 1 - div);
    ans += 1ll * b * (M - 2 * div);
    ans += l + (N - r % N);
    printf("%lld\n", ans);
  }
  return 0;
}
