#include <bits/stdc++.h>
const double Pi = acos(-1.0);
using namespace std;
long long n, k, m;
deque<pair<int, int> > bus;
int main(int argc, char** argv) {
  scanf("%lld %lld %lld", &n, &k, &m);
  int a;
  long long tot = 0;
  pair<int, int> cur = pair<int, int>(-1, -1);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    tot++;
    if (a != cur.first) {
      if (cur.first != -1) bus.push_back(cur);
      cur = pair<int, int>(a, 1);
    } else {
      cur.second++;
      if (cur.second == k) {
        tot -= k;
        if (!bus.empty()) {
          cur = bus.back();
          bus.pop_back();
        } else
          cur = pair<int, int>(-1, -1);
      }
    }
  }
  if (cur.first != -1 && cur.second != k) bus.push_back(cur);
  int sz = bus.size();
  long long del = 0;
  while (!bus.empty()) {
    pair<int, int> b = bus.back(), f = bus.front();
    if (b.first != f.first) break;
    int add = b.second + f.second;
    if (add >= k) del += k;
    if (add != k) break;
    bus.pop_back();
    if (!bus.empty()) bus.pop_front();
  }
  if (bus.empty())
    printf("%lld\n", (m & 1) * tot);
  else {
    if ((sz & 1) && (int)bus.size() == 1) {
      long long rem = bus.back().second, mid = (rem * m) % k;
      printf("%lld\n", (mid) ? tot - rem + mid : 0);
    } else
      printf("%lld\n", m * tot - (m - 1) * del);
  }
  return 0;
}
