#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int n, k, m, a[MAXN];
long long S[MAXN][2];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  memset(S, 0, sizeof(S));
  int top = 0;
  for (int i = 0; i < n; i++) {
    if (!top || S[top][0] != a[i]) {
      S[++top][0] = a[i];
      S[top][1] = 1;
    } else
      S[top][1]++;
    if (S[top][1] == k) S[top--][1] -= k;
  }
  long long sum = 0;
  for (int i = 1; i <= top; i++) sum += S[i][1];
  int s = 1, e = top;
  while (s < e && S[s][0] == S[e][0]) {
    if ((S[s][1] + S[e][1]) % k == 0) {
      s++, e--;
    } else {
      S[s][1] = (S[s][1] + S[e][1]) % k;
      S[e][1] = 0;
      break;
    }
  }
  long long mid = 0;
  for (int i = s; i <= e; i++) mid += S[i][1];
  long long ans;
  if (s == e) {
    if (((long long)m * mid) % k == 0)
      ans = 0;
    else {
      ans = ((long long)m * mid) % k;
      ans += sum;
      ans -= mid;
    }
  } else if (s < e) {
    ans = sum + (long long)mid * (m - 1);
  } else if (s > e) {
    ans = 0;
  }
  printf("%lld\n", ans);
}
