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;
int N, K, M;
vector<int> arr;
vector<pair<int, int> > tmp, sub;
int main() {
  scanf("%d %d %d", &N, &K, &M);
  arr.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
    arr[i]--;
  }
  bool ok = true;
  int c = arr[0];
  for (int i = 0; i < N; i++) {
    if (arr[i] != c) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << 1LL * N * M % K;
    return 0;
  }
  int col, cnt;
  for (int i = 0; i < N; i++) {
    if (i == 0 || arr[i - 1] != arr[i]) {
      if (i) tmp.push_back(pair<int, int>(col, cnt));
      col = arr[i];
      cnt = 1;
    } else
      cnt++;
  }
  tmp.push_back(pair<int, int>(col, cnt));
  long long rem = 0;
  for (int i = 0; i < tmp.size(); i++) {
    rem += 1LL * M * (tmp[i].second / K) * K;
    tmp[i].second %= K;
    if (tmp[i].second == 0) {
      continue;
    }
    if (sub.size() == 0 || sub.back().first != tmp[i].first)
      sub.push_back(tmp[i]);
    else {
      sub.back().second += tmp[i].second;
      rem += (sub.back().second / K) * K;
      sub.back().second %= K;
      if (sub.back().second == 0) sub.pop_back();
    }
  }
  tmp = sub;
  if (tmp.size() == 0) {
    cout << 0;
    return 0;
  }
  if (tmp.size() == 1) {
    cout << 1LL * tmp[0].second * M % K;
    return 0;
  }
  if (M == 1) {
    cout << (long long)N - rem;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    if (tmp[i].first != tmp[N - 1 - i].first) break;
    if (i == N - 1) {
      cout << (tmp[i].second + tmp[N - 1 - i].second) % K;
      return 0;
    }
    rem += 1LL * (M - 1) * ((tmp[i].second + tmp[N - 1 - i].second) / K) * K;
    if ((tmp[i].second + tmp[N - 1 - i].second) % K) break;
  }
  cout << 1LL * N * M - rem;
}
