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 main() {
  long long int n, k, m;
  cin >> n >> k >> m;
  long long int temp;
  vector<pair<long long int, long long int>> A;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if ((!A.empty()) && (temp == A.back().first)) {
      A.back().second++;
      if (A.back().second == k) A.pop_back();
    } else {
      A.push_back(make_pair(temp, 1));
    }
  }
  long long int count = 0;
  long long int total = 0;
  int start = 0, end = A.size() - 1;
  for (auto i : A) total += i.second;
  total *= m;
  while (start < end) {
    if (A[start].first != A[end].first) break;
    if (A[start].second + A[end].second > k) {
      count += (m - 1) * k;
      break;
    }
    if (A[start].second + A[end].second == k) {
      count += (m - 1) * k;
      start++;
      end--;
    }
  }
  if (start > end) return !(cout << "0");
  if (start == end) {
    long long int x = A[start].second * m;
    if (x % k == 0) {
      return !(cout << "0");
    } else {
      return !(cout << x % k);
    }
  }
  cout << total - count;
  return 0;
}
