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 N, K, M, ret;
stack<long long> ori, compress;
deque<long long> nums;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(18);
  cin >> N >> K >> M;
  ret = N * M;
  for (long long i = 0; i < N; i++) {
    long long x;
    cin >> x;
    if (ori.size() == 0 || ori.top() != x) {
      ori.push(x);
      compress.push(1);
    } else {
      long long temp = compress.top();
      compress.pop();
      compress.push(temp + 1);
    }
    if (compress.top() == K) {
      ret -= K * M;
      ori.pop();
      compress.pop();
    }
  }
  while (ori.size() > 0) {
    for (long long i = 0; i < compress.top(); i++) nums.push_front(ori.top());
    ori.pop();
    compress.pop();
  }
  while (nums.size() > 0) {
    long long cnt = 0, x = nums.front();
    while (nums.size() > 0 && nums.front() == x) {
      cnt++;
      nums.pop_front();
    }
    while (nums.size() > 0 && nums.back() == x) {
      cnt++;
      nums.pop_back();
    }
    if (nums.size() == 0) {
      long long sub = cnt * M;
      if (sub % K == 0) {
        ret = 0;
        break;
      } else
        ret -= (sub / K) * K;
    } else if (cnt % K == 0)
      ret -= cnt * (M - 1);
    else {
      ret -= (cnt / K) * K * (M - 1);
      break;
    }
  }
  cout << ret << '\n';
  return 0;
}
