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;
long long solve() {
  long long n, m, k, i, x;
  cin >> n >> k >> m;
  vector<long long> v;
  long long pv = -1, cnt = 1;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (x == pv) {
      cnt++;
      v.push_back(x);
      if (cnt == k) {
        while (cnt--) v.pop_back();
      }
    } else
      v.push_back(x), cnt = 1;
    pv = x;
  }
  long long ans = v.size() * m;
  if (ans == 0 or k == 1) return cout << 0 << endl, 0;
  pv = v.back();
  n = v.size();
  cnt = 0;
  for (i = 0; i < n; i++) {
    long long cnt2 = 0, j = n - 1;
    while (v[i] == pv and i <= j) i++, cnt++;
    while (v[j] == pv and i < j) j--, cnt++, cnt2++;
    cnt2 = min(cnt2, 1LL);
    if (j == i - 1) {
      cnt *= m;
      cnt = (cnt / k) * k;
      ans -= cnt;
      while (n--) v.pop_back();
      break;
    } else {
      while (cnt2--) v.pop_back();
      i--;
      pv = v.back();
      long long rmv = cnt / k * (m)*k;
      ans -= rmv;
      if (cnt % k) break;
      cnt = 0;
      n = v.size();
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
