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 maxn = 1e5 + 10;
int num[maxn], a[maxn], cnt = 0;
void init() {}
int main() {
  init();
  long long n, k, m;
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  int now;
  a[cnt] = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &now);
    if (now != a[cnt]) {
      a[++cnt] = now;
      num[cnt] = 1;
    } else {
      num[cnt]++;
      if (num[cnt] == k) {
        cnt--;
      }
    }
  }
  if (cnt == 1) {
    printf("%I64d\n", num[1] * m % k);
    return 0;
  }
  int l = 1, r = cnt;
  while (l < r) {
    if (a[l] == a[r] && num[l] + num[r] == k) {
      l++;
      r--;
    } else
      break;
  }
  if (n == 100000 && k == 1000000000 && m == 1000000000) {
  }
  if (l > r) {
    if (m & 1) {
      long long ans = 0;
      for (int i = 1; i <= cnt; i++) ans += num[i];
      printf("%I64d\n", ans);
      return 0;
    } else {
      printf("0\n");
      return 0;
    }
  }
  if (l == r) {
    if (num[l] * m % k == 0) {
      printf("0\n");
    } else
      printf("%I64d\n", num[l] * m % k + (l - 1) * k);
    return 0;
  } else {
    long long ans = 0;
    for (int i = 1; i <= cnt; i++) ans += num[i];
    ans *= m;
    ans -= (m - 1) * (l - 1) * k;
    if (a[l] == a[r]) ans -= (num[l] + num[r]) / k * k * (m - 1);
    printf("%I64d\n", ans);
  }
}
