#include <bits/stdc++.h>
using namespace std;
const long dad = 2e5;
unsigned long long n, m, k, ans, n2;
pair<unsigned long long, unsigned long long> a[dad];
bool check(int l1, int r1) {
  if (a[l1].first != a[r1].first) return 0;
  if (l1 == r1) {
    ans = (unsigned long long)ans + a[l1].second * m - ((a[l1].second * m) % k);
    if ((a[l1].second * m) % k == 0)
      return 1;
    else
      return 0;
  } else {
    if (a[l1].second + a[r1].second == k) {
      ans = (unsigned long long)ans + k * (m - 1);
      if (check(l1 + 1, r1 - 1) == 1) {
        ans += k;
        return 1;
      } else
        return 0;
    } else {
      if (a[l1].second + a[r1].second > k) {
        ans = (unsigned long long)ans + k * (m - 1);
        return 0;
      } else
        return 0;
    }
  }
}
void input() {
  scanf("%lld%lld%lld", &n, &k, &m);
  for (int i = 1; i <= n; ++i) {
    int u;
    scanf("%lld", &u);
    if (u == a[n2].first)
      ++a[n2].second;
    else
      a[++n2] = {u, 1};
    if (a[n2].second >= k) {
      ans = (unsigned long long)ans + k * m;
      --n2;
    }
  }
  if (n2 == 1) {
    cout << (n * m - ans) % k;
    return;
  }
  check(1, n2);
  cout << n * m - ans;
}
void output() {}
int main() {
  input();
  output();
  return 0;
}
