#include <bits/stdc++.h>
using namespace std;
const long double pi = acosl(-1);
const int maxn = 100010;
const long long mod = 1e6 + 3;
const int inf = 1e9;
int n, k, m;
int a[maxn];
deque<pair<int, int> > vec;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int s = n;
  for (int i = 0; i < n; i++) {
    if (!vec.empty() && vec.back().first == a[i]) {
      vec.back().second++;
    } else {
      vec.push_back({a[i], 1});
    }
    if (!vec.empty() && vec.back().second == k) {
      vec.pop_back();
      s -= k;
    }
  }
  long long sum = (long long)s * m;
  if (m == 1) {
    cout << sum << endl;
    return 0;
  }
  long long pr = 0;
  while (vec.size() >= 2 && vec[0].first == vec.back().first) {
    if (vec[0].second + vec.back().second == k) {
      vec.pop_back();
      vec.pop_front();
      sum -= (long long)k * (m - 1);
      pr += k;
    } else if (vec[0].second + vec.back().second > k) {
      int tmp = vec[0].second + vec.back().second - k;
      vec.back().second = 0;
      vec[0].second = tmp;
      sum -= (long long)k * (m - 1);
      break;
    } else {
      break;
    }
  }
  if (vec.size() == 1) {
    long long tmp = (long long)vec[0].second * m;
    sum = tmp % k;
    if (sum) sum += pr;
  }
  cout << sum << endl;
  return 0;
}
