#include <bits/stdc++.h>
using namespace std;
long long a[101000], c[101000], num[101000];
int main() {
  long long n, cir, m;
  while (scanf("%lld%lld%lld", &n, &cir, &m) != EOF) {
    long long cnt = 0;
    for (long long i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      if (a[i] != c[cnt]) {
        c[++cnt] = a[i];
        num[cnt] = 1;
      } else {
        num[cnt]++;
        if (num[cnt] == cir) cnt--;
      }
    }
    if (!cnt) {
      printf("0\n");
      continue;
    }
    long long sum = 0;
    for (long long i = 1; i <= cnt; i++) sum += num[i];
    long long k, k1;
    long long s = 0;
    for (k = 1, k1 = cnt + 1 - k; k < k1; k++, k1--) {
      if (c[k] == c[k1] && num[k] + num[k1] == cir)
        s = s + cir;
      else
        break;
    }
    if (k < k1) {
      if (c[k] == c[k1] && num[k] + num[k1] > cir) s = s + cir;
      printf("%lld\n", sum * m - s * (m - 1));
    } else if (k == k1) {
      long long ans = (num[k] * m) % cir;
      if (ans) ans += sum - num[k];
      cout << ans << endl;
    }
  }
  return 0;
}
