#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000 * 1000 * 1000 + 1;
const long long MOD = 1000 * 1000 * 1000 + 7;
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  vector<vector<long long>> bus;
  int city;
  long long sum{n};
  for (int i = 0; i < n; ++i) {
    cin >> city;
    if (bus.size() && bus[bus.size() - 1][0] == city) {
      ++bus.back()[1];
      if (bus.back()[1] == k) {
        bus.pop_back();
        sum -= k;
      }
    } else {
      bus.push_back({city, 1});
    }
  }
  long long sumAll{sum};
  int pos = 0;
  int sz = bus.size();
  long long pref = 0;
  while (pos < bus.size() && bus[pos][0] == bus[sz - 1 - pos][0]) {
    if (bus[pos][1] + bus[sz - 1 - pos][1] >= k) {
      sum -= k;
      pref += k;
      if (bus[pos][1] + bus[sz - 1 - pos][1] == k) {
        ++pos;
      } else {
        break;
      }
    } else {
      break;
    }
  }
  --pos;
  if (pos == sz - 1) {
    cout << ((m & 1) ? sumAll : 0) << endl;
    return 0;
  }
  if ((sz & 1) && pos + 1 == sz / 2) {
    sumAll -= bus[sz / 2][1];
    long long mod = (bus[sz / 2][1] * m) % k;
    sumAll += mod;
    cout << (mod ? sumAll : 0) << endl;
    return 0;
  }
  cout << sum * m + pref << endl;
  return 0;
}
