#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k, m;
  vector<pair<int, int>> from;
  cin >> n >> k >> m;
  long long preteam = 0ll;
  for (int i = (0); i < (n); ++i) {
    int a;
    cin >> a;
    if (!from.empty() && from.back().first == a) {
      ++from.back().second;
      if (from.back().second == k) {
        ++preteam;
        from.pop_back();
      }
    } else {
      from.emplace_back(a, 1);
    }
  }
  long long edgeteam = 0ll;
  auto froml = from.begin();
  auto fromr = from.end();
  while (fromr - froml >= 2) {
    auto prer = fromr - 1;
    if (froml->first != prer->first) {
      break;
    } else {
      long long concat = froml->second + prer->second;
      edgeteam += concat / k;
      if (concat % k != 0)
        break;
      else {
        ++froml;
        --fromr;
      }
    }
  }
  long long centerteam = 0ll;
  if (fromr - froml == 1) {
    long long center = m * froml->second;
    if (center % k == 0) {
      cout << 0 << endl;
      return 0;
    } else {
      centerteam = center / k;
    }
  }
  cout << n * m - preteam * k * m - edgeteam * k * (m - 1) - centerteam * k
       << endl;
  return 0;
}
