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;
deque<pair<long long, long long> > what;
long long all[100005];
int main() {
  long long N, M, K, i, ok = 1, ans = 0;
  pair<long long, long long> t, t2;
  scanf("%lld %lld %lld", &N, &K, &M);
  for (i = 0; i < N; i++) {
    scanf("%lld", &all[i]);
    if (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;
      while (1) {
        t = what.back();
        what.pop_back();
        if (!what.empty()) {
          t2 = what.back();
          if (t2.first == t.first) {
            t2.second += t.second;
            t2.second % K;
            if (t2.second % K)
              what.push_back(t2);
            else
              N -= K;
          } else {
            what.push_back(t);
            break;
          }
        }
      }
    }
  }
  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;
}
