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;
const int MOD = 1000000007;
int N, K, M;
pair<long long, deque<pair<int, long long>>> get(
    const deque<pair<int, long long>> d) {
  long long result = 0;
  deque<pair<int, long long>> r;
  for (auto p : d) {
    if (r.empty() || r.back().first != p.first) r.push_back({p.first, 0});
    r.back().second += p.second;
    result += r.back().second / K;
    r.back().second %= K;
    if (!r.back().second) r.pop_back();
  }
  return make_pair(result, r);
}
int main() {
  scanf("%d%d%d", &N, &K, &M);
  deque<pair<int, long long>> A;
  for (int i = 0; i < (N); ++i) {
    int a;
    scanf("%d", &a);
    A.push_back({a, 1});
  }
  auto p = get(A);
  A = p.second;
  long long result = p.first;
  if (M == 1) {
    cout << N * (long long)M - result * (long long)K << endl;
    return 0;
  } else if (A.size() == 1) {
    result += A[0].second * M / K;
    cout << N * (long long)M - result * (long long)K << endl;
    return 0;
  }
  deque<pair<int, long long>> first, last;
  while (A.size() >= 2) {
    if (A.back().first != A.front().first) break;
    first.push_back(A.front());
    last.push_front(A.back());
    result += (A.back().second + A.front().second) * (long long)(M - 1) / K;
    A.back().second += A.front().second;
    A.back().second %= K;
    A.pop_front();
    if (!A.back().second) A.pop_back();
  }
  if (A.size() == 1) {
    first.push_back({A[0].first, A[0].second * M});
    first.insert(first.end(), last.begin(), last.end());
    result += get(first).first;
  }
  cout << N * (long long)M - result * (long long)K << endl;
}
