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;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k, m;
  cin >> n >> k >> m;
  vector<int> bus;
  for (int i = 0; i < n; i++) {
    int cur;
    cin >> cur;
    bus.push_back(cur);
  }
  long long cursz = 1;
  set<int> keep;
  for (int i = 0; i < n; i++) {
    keep.insert(i);
  }
  for (int i = 1; i < n; i++) {
    if (bus[i] == bus[i - 1]) {
      cursz++;
    } else {
      cursz = 1;
    }
    if (cursz == k) {
      for (int j = i; j > i - k; j--) {
        keep.erase(j);
      }
      cursz = 0;
    }
  }
  vector<int> newBus;
  for (int i : keep) {
    newBus.push_back(bus[i]);
  }
  bus = newBus;
  int i = bus.size() - 1;
  int j = 0;
  cursz = 0;
  long long totSz = bus.size() * m;
  while (true) {
    if (bus[i] == bus[j]) {
      cursz = 2;
      if (i == j) cursz = 1;
    } else {
      break;
    }
    while (bus[i] == bus[i - 1] && i > 0) {
      i--;
      cursz++;
    }
    while (bus[j] == bus[j + 1] && j < i) {
      j++;
      cursz++;
    }
    if (i == j) {
      totSz -= (m * cursz / k) * k;
      if ((m * cursz % k) == 0) {
        totSz = 0;
      }
    }
    totSz -= (m - 1) * (cursz / k) * k;
    if (cursz % k != 0) break;
    i--;
    j++;
    if (i < 0 || j == bus.size() - 1) break;
  }
  cout << totSz << endl;
  return 0;
}
