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>
#pragma GCC target("avx,tune=native")
using namespace std;
int n, k, m;
deque<pair<int, int> > q;
int main() {
  if (fopen("FILENAME.in", "r")) {
    freopen("FILENAME.in", "r", stdin);
    freopen("FILENAME.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (q.size() && q.back().first == x) {
      q.back().second++;
      if (q.back().second >= k) q.pop_back();
    } else {
      q.push_back(make_pair(x, 1));
    }
  }
  long long ans = 0;
  while (q.size() > 1) {
    if (q.front().first != q.back().first) break;
    int sum = q.front().second + q.back().second;
    if (sum >= k) {
      ans += k;
      int color = q.front().first;
      q.pop_front();
      q.pop_back();
      if (sum > k) {
        q.push_front(make_pair(0, sum - k));
        break;
      }
    } else
      break;
  }
  if (q.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (q.size() == 1) {
    long long remainder = ((1LL * m * q.front().second) % k);
    if (remainder == 0) {
      cout << 0 << endl;
      return 0;
    }
    cout << ans + remainder << endl;
    return 0;
  }
  int total = 0;
  for (pair<int, int> a : q) {
    total += a.second;
  }
  cout << ans + 1LL * m * total << endl;
}
