#include <bits/stdc++.h>
using namespace std;
long long n, k, m, in, mns;
vector<long long> cnt, num, cntt, numm;
int32_t main(void) {
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  for (long long i = 0; i < n; ++i) {
    scanf("%I64d", &in);
    if (cnt.empty()) {
      cnt.push_back(1);
      num.push_back(in);
    } else if (in == num.back()) {
      cnt.back()++;
      if (cnt.back() == k) cnt.pop_back(), num.pop_back(), mns += k;
    } else {
      cnt.push_back(1);
      num.push_back(in);
    }
  }
  long long ans = (n - mns) * m, cur;
  for (cur = 0; cur < (long long)num.size() / 2; cur++) {
    if (num[cur] == num[(long long)num.size() - cur - 1]) {
      ans -=
          (cnt[cur] + cnt[(long long)num.size() - cur - 1]) / k * k * (m - 1);
      if ((cnt[cur] + cnt[(long long)num.size() - cur - 1]) % k) {
        break;
      }
    } else {
      break;
    }
  }
  if (cur == (long long)num.size() / 2) {
    if ((long long)num.size() & 1) {
      mns = cnt[cur] * m / k * k;
      ans -= mns;
      if (cnt[cur] * m % k == 0) {
        for (long long i = 0; i < (long long)cnt.size(); ++i) {
          if (i == cur) continue;
          if ((long long)numm.size() && numm.back() == num[i]) {
            cntt.back() += cnt[i];
          } else {
            numm.push_back(num[i]);
            cntt.push_back(cnt[i]);
          }
          ans -= cntt.back() / k * k;
          cntt.back() %= k;
          if (cntt.back() == 0) numm.pop_back(), cntt.pop_back();
        }
      }
    } else {
      ans = 0;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
