#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  if (0) return;
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  if (0) return;
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;
void solve() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<long long> arr(n);
  long long mx = -1, mn = INF;
  for (long long i = 0; i < (long long)n; i++)
    cin >> arr[i], mx = max(mx, arr[i]), mn = min(mn, arr[i]);
  if (mn == mx) {
    cout << (n * m) % k << '\n';
    return;
  }
  long long cnt = 0, total = n * m, avail = 0;
  vector<pair<long long, long long> > temp;
  for (long long i = 0; i < (long long)n; i++) {
    if (temp.size() == 0 or arr[i] != temp.back().first)
      cnt = 1;
    else
      cnt++;
    temp.push_back({arr[i], cnt});
    if (cnt == k) {
      avail++;
      while (cnt--) temp.pop_back();
      if (temp.size()) cnt = temp.back().second;
    }
  }
  avail = avail * k * m;
  n = temp.size();
  arr.clear();
  for (auto& i : temp) arr.push_back(i.first);
  n = arr.size();
  vector<pair<long long, long long> > front, backk;
  long long cntf = 0;
  for (long long i = 0; i < (long long)n; i++) {
    if (!i or arr[i] != arr[i - 1])
      front.push_back({arr[i], 1}), cntf++;
    else
      front.back().second++;
  }
  long long cntb = 0;
  for (long long i = n - 1; i >= 0; i--) {
    if (i == n - 1 or arr[i] != arr[i + 1])
      backk.push_back({arr[i], 1}), cntb++;
    else
      backk.back().second++;
  }
  assert(cntf == cntb);
  long long el = 0, el2 = cntb - 1;
  while (el <= el2 and el < cntf and front[el].first == backk[el].first) {
    long long sum = front[el].second + backk[el].second;
    if (el < el2 and sum < k) break;
    long long add = sum * (m - 1);
    if (el < el2 and sum % k != 0) {
      avail += (k) * (m - 1);
      break;
    }
    if (el == el2) add = (sum / 2) * m;
    avail += (add) - (add % k);
    if (add % k != 0) break;
    if (el == el2) {
      el++;
      el2--;
      while (el < cntf and front[el].first == backk[el].first) {
        long long sum2 = front[el].second + backk[el].second;
        assert(sum2 < 2 * k);
        if (sum2 < k) break;
        avail += k;
        if (sum2 % k != 0) break;
        el++;
      }
    }
    el++;
    el2--;
  }
  long long res = total - avail;
  cout << res << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  while (test--) solve();
}
