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;
int k;
long long find_sum(deque<pair<int, long long> > inp) {
  long long ans = 0;
  while (!inp.empty()) {
    ans += inp.back().second;
    inp.pop_back();
  }
  return ans;
}
long long find_rem(deque<pair<int, long long> > inp) {
  deque<pair<int, long long> > runs = inp;
  while (!inp.empty()) {
    auto p = inp.front();
    inp.pop_front();
    if (!runs.empty() && runs.back().first == p.first)
      runs.back().second = runs.back().second + p.second;
    else
      runs.push_back(p);
    runs.back().second %= k;
    if (runs.back().second == 0) runs.pop_back();
  }
  return find_sum(runs);
}
int main() {
  int n, m;
  scanf("%d %d %d", &n, &k, &m);
  int tmp;
  scanf("%d", &tmp);
  deque<pair<int, long long> > runs;
  runs.emplace_back(tmp, 1);
  for (int i = 1; i < n; i++) {
    scanf("%d", &tmp);
    if (tmp == runs.back().first)
      runs.back().second++;
    else
      runs.emplace_back(tmp, 1);
    runs.back().second %= k;
    if (runs.back().second == 0) runs.pop_back();
  }
  long long ans = find_sum(runs);
  long long rem = find_rem(runs);
  long long deletion = 2 * ans - rem;
  if (runs.size() <= 1)
    printf("%lld\n", m * ans % k);
  else if (deletion >= ans)
    printf("0\n");
  else
    printf("%lld\n", m * ans - (m - 1) * deletion);
}
