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>
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) {
        cur = pair<int, int>(-1, -1);
        tot -= k;
      }
    }
  }
  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;
}
