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;
long long n, k, m, ans;
long long a[100200], p[100200], ct[100200], cnt;
int main() {
  scanf("%lld%lld%lld", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1, j = 1; i <= n; i = j) {
    for (; a[i] == a[j] && j <= n; j++)
      ;
    if ((j - i) % k) {
      ct[++cnt] = (j - i) % k;
      p[cnt] = a[i];
      if (cnt > 1 && p[cnt] == p[cnt - 1]) {
        cnt--;
        ct[cnt] = (ct[cnt] + ct[cnt + 1]) % k;
        if (!ct[cnt]) cnt--;
      }
    }
  }
  int i = 1, j = cnt, el = 0;
  while (p[i] == p[j] && (ct[i] + ct[j]) % k == 0 && i <= j)
    el += ct[i++] + ct[j--];
  if (i < j) {
    if (p[i] == p[j]) el += ct[i] + ct[j] - (ct[i] + ct[j]) % k;
    for (int l = 1; l <= cnt; l++) ans += ct[l];
    ans = ans * m - el * (m - 1);
  } else if (i == j) {
    int po = ct[i] * m % k;
    if (po) {
      for (int l = 1; l <= cnt; l++) ans += ct[l];
      ans -= ct[i] - po;
    }
  } else if (m % 2) {
    for (int i = 1; i <= cnt; i++) ans += ct[i];
  }
  printf("%lld\n", ans);
  return 0;
}
