10 5 1000000000
1 1 1 2 2 1 2 2 2 2
 5 3 3
1 2 2 1 1
 2 4 1
1 1
 1 1000000000 1000000000
100000
 5 3 2
1 1 2 1 1
 5 2 4
1 2 3 2 1
 1 10 10
1

10000000000
 0
 2
 0
 7
 0
 0

#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;
  long long suff = 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 += bus[pos][1];
      suff += bus[sz - 1 - pos][1];
      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 + suff << endl;
  return 0;
}
