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 N = 100002;
int n, k, m, cnt;
int a[N], b[N], c[N];
long long ans = 0;
int main() {
  cnt = 0;
  int i, j, o, sum = 0;
  int l, r;
  scanf("%d%d%d", &n, &k, &m);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 1; i <= n; ++i) {
    if (a[i] != b[cnt]) {
      b[++cnt] = a[i];
      c[cnt] = 1;
    } else {
      c[cnt]++;
      if (c[cnt] == k) cnt--;
    }
  }
  if (!cnt) {
    puts("0");
    return 0;
  }
  for (i = 1; i <= cnt; ++i) sum += c[i];
  for (o = 0, i = 1; i < cnt + 1 - i; ++i) {
    if (b[i] == b[cnt + 1 - i] && c[i] + c[cnt + 1 - i] == k)
      o += k;
    else
      break;
  }
  if (i < cnt + 1 - i) {
    if (b[i] == b[cnt + 1 - i] && c[i] + c[cnt + 1 - i] > k) o += k;
    ans = 1ll * sum * m - 1ll * o * (m - 1);
  } else {
    ans = 1ll * c[i] * m % k;
  }
  printf("%lld\n", ans);
  return 0;
}
