#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * 1e5;
vector<long long> a;
long long num[N], n, k, m, val;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> val;
    if (a.size() && a.back() == val) {
      ++num[a.size() - 1];
      if (num[a.size() - 1] == k) a.pop_back();
    } else {
      num[a.size()] = 1;
      a.push_back(val);
    }
  }
  long long x = 0, y = a.size() - 1, b = 0;
  for (int i = 0; i < a.size(); ++i) b += num[i];
  if (m == 1) {
    cout << b;
    return 0;
  }
  int tmp = b;
  while (x < y) {
    if (a[x] != a[y]) break;
    if (num[x] + num[y] == k) {
      b -= k;
      ++x;
      --y;
      continue;
    }
    if (num[x] + num[y] > k) b -= k;
    break;
  }
  long long ans = m * b;
  tmp -= b;
  if (x == y) {
    if (ans % k == 0) tmp = 0;
    ans = ans % k;
  }
  cout << ans + tmp;
  return 0;
}
