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 mod = 1000000007;
const long long oo = 1000000000000000000LL;
inline int add(int a, int b) {
  if ((a += b) >= mod)
    return a - mod;
  else
    return a;
}
inline int mul(int a, int b) { return long long(a) * b % mod; }
inline int sub(int a, int b) {
  if ((a -= b) < 0)
    return a + mod;
  else
    return a;
}
int power(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}
const int N = 100005;
int ds[N], cnt[N];
int main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  int sz = 0;
  long long ans = n * m;
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    if (sz > 0 && ds[sz] == a) {
      cnt[sz]++;
      a = 0;
      if (cnt[sz] == k) {
        ans -= long long(k) * m;
        --sz;
      }
    }
    if (a > 0) {
      ds[++sz] = a;
      cnt[sz] = 1;
    }
  }
  if (m > 1) {
    int i = 1, j = sz;
    for (; i < j; i++, j--) {
      if (ds[i] != ds[j]) break;
      int t = cnt[i] + cnt[j];
      int z = t / k;
      if (z > 0) ans -= long long(z) * long long(k) * (m - 1);
      if (t % k != 0) break;
    }
    if (i == j) {
      long long t = long long(cnt[i]) * m;
      long long z = t / k;
      if (z > 0) ans -= z * long long(k);
      if (t % k == 0) {
        ans = 0;
      }
    }
  }
  printf("%lld", ans);
}
