#include <bits/stdc++.h>
using namespace std;
int n, m, k, r;
long long c;
vector<int> V;
deque<pair<int, int> > D;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &r);
    if (D.size() == 0) {
      D.push_back(make_pair(r, 1));
      continue;
    }
    if (r == D.back().first)
      D.back().second++;
    else
      D.push_back(make_pair(r, 1));
    if (D.back().second == k) D.pop_back();
  }
  for (int i = 0; i < D.size(); i++) c += 1ll * D[i].second;
  c *= 1ll * m;
  while (D.size() > 1) {
    if (D.front().first != D.back().first) {
      break;
    }
    c -= ((1ll * (D.front().second + D.back().second) / k) * k * (m - 1));
    if ((D.back().second + D.front().second) % k != 0) {
      break;
    }
    V.push_back(D.front().second + D.back().second);
    D.pop_front();
    D.pop_back();
  }
  if (D.size() == 1) {
    c -= (1ll * m * D.front().second / k * k);
    if ((1ll * D.front().second * m) % k == 0) {
      D.pop_front();
    }
  }
  if (D.size() == 0) {
    for (int i = 0; i < (int)V.size(); i++) c -= V[i];
  }
  printf("%I64d", c);
  return (0);
}
