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;
long long arr[100000];
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> K >> M;
  for (int i = 0; i < N; i++) cin >> arr[i];
  if (K == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<pair<int, vector<int> > > S;
  for (int i = 0; i < N; i++) {
    if (S.empty() || S.back().first != arr[i]) {
      S.push_back(make_pair(arr[i], vector<int>()));
      S.back().second.push_back(i);
    } else {
      S.back().second.push_back(i);
    }
    if (S.back().second.size() == K) {
      for (int j = 0; j < S.back().second.size(); j++) {
        arr[S.back().second[j]] = -1;
      }
      S.pop_back();
    }
  }
  if (S.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (S.size() == 1) {
    cout << ((long long)S.back().second.size() * M) % K << endl;
    return 0;
  }
  int lptr = 0, rptr = S.size() - 1;
  long long adjust = 0;
  while (lptr < rptr && S[lptr].first == S[rptr].first) {
    long long sz = S[lptr].second.size() + S[rptr].second.size();
    adjust = sz % K;
    lptr++, rptr--;
    if (sz % K != 0) {
      break;
    }
  }
  if (lptr == rptr && adjust == 0) {
    cout << ((long long)S[lptr].second.size() * M) % K << endl;
    return 0;
  }
  long long fullsz = 0, insz = adjust;
  for (int i = 0; i < S.size(); i++) {
    fullsz += S[i].second.size();
    if (i >= lptr && i <= rptr) insz += S[i].second.size();
  }
  long long ans = insz * (M - 1) + fullsz;
  cout << ans << endl;
  return 0;
}
