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 int alln, allk, allm;
long long int a;
deque<pair<long long int, long long int> > dq;
int main() {
  scanf("%lld%lld%lld", &alln, &allk, &allm);
  long long int ans = alln;
  for (int i = 0; i < alln; ++i) {
    scanf("%lld", &a);
    if (!dq.empty() && dq.back().first == a)
      ++dq.back().second;
    else
      dq.push_back({a, 1});
    if (dq.back().second == allk) {
      ans -= allk;
      dq.pop_back();
    }
  }
  ans *= allm;
  while (dq.size() > 1 && dq.back().first == dq.front().first) {
    ans -=
        (((dq.back().second + dq.front().second) / allk) * allk) * (allm - 1);
    if ((dq.back().second + dq.front().second) % allk == 0) {
      dq.pop_front();
      dq.pop_back();
    } else
      break;
  }
  if (dq.size() == 1) {
    if ((dq.front().second * allm) % allk)
      ans -= ((dq.front().second * allm) / allk) * allk;
    else
      ans = 0;
  }
  printf("%lld", ans);
  return 0;
}
