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(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;
}
