#include <bits/stdc++.h>
using namespace std;
long long n, k, m, t;
long long matched = 0, head_tail = 0, middle = 0;
deque<pair<long long, long long>> dq;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> t;
    if (dq.empty() || dq.back().first != t) {
      dq.push_back({t, 1});
    } else {
      dq.back().second++;
      if (dq.back().second == k) {
        dq.pop_back();
        middle++;
      }
    }
  }
  while (dq.size() >= 2) {
    if (dq.front().first == dq.back().first &&
        dq.front().second + dq.back().second >= k) {
      head_tail++;
      if (dq.front().second + dq.back().second == k) {
        dq.pop_front();
      }
      dq.pop_back();
    } else {
      break;
    }
  }
  matched += middle * m;
  matched += head_tail * (m - 1);
  if (dq.size() == 1) {
    matched += dq.front().second * m / k;
    if (dq.front().second * m % k == 0) {
      matched += head_tail;
    }
  }
  cout << m * n - matched * k << endl;
  return 0;
}
