#include <bits/stdc++.h>
using namespace std;
deque<pair<long long, long long> > what;
long long all[100005];
int main() {
  long long N, M, K, i, ok = 1, ans = 0, xx;
  pair<long long, long long> t, t2;
  scanf("%lld %lld %lld", &N, &K, &M);
  xx = N;
  for (i = 0; i < xx; i++) {
    scanf("%lld", &all[i]);
    if (i && all[i] != all[i - 1]) ok = 0;
    if (what.empty() || what.back().first != all[i])
      what.push_back(make_pair(all[i], 1));
    else {
      t = what.back();
      what.pop_back();
      t.second++;
      if (t.second != K)
        what.push_back(t);
      else
        N -= K;
    }
  }
  if (ok)
    printf("%lld\n", N * M % K);
  else if (M == 1)
    printf("%lld\n", N);
  else {
    ans = N * M;
    while (what.size() >= 2 && what.front().first == what.back().first &&
           what.front().second + what.back().second >= K) {
      ans -= K * (M - 1);
      t = what.front();
      what.pop_front();
      t.second -= (K - what.back().second);
      what.pop_back();
      if (t.second) what.push_front(t);
    }
    if (what.size() == 1) {
      ans -= M * what.front().second / K * K;
      if (M * what.front().second % K == 0) ans = 0;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
