#include <bits/stdc++.h>
using i64 = long long;
template <class T>
std::vector<T> read(int n) {
  std::vector<T> res(n);
  for (auto& r : res) {
    std::cin >> r;
  }
  return res;
}
i64 solve(std::deque<std::pair<int, int>>& a, i64 n, i64 k, i64 m) {
  if (a.size() <= 1) {
    return n * m % k;
  }
  auto l = a.front(), r = a.back();
  a.pop_front(), a.pop_back();
  if (l.first != r.first) {
    return n * m;
  }
  i64 len = l.second + r.second;
  if (len % k) {
    return n * m - len / k * k * (m - 1);
  }
  i64 rem = solve(a, n - len, k, m);
  if (rem == 0) {
    return 0;
  } else {
    return rem + len;
  }
}
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
  int n, k, m;
  std::cin >> n >> k >> m;
  auto a = read<int>(n);
  std::deque<std::pair<int, int>> runs;
  for (int i = 0; i < n; i++) {
    runs.push_back({a[i], 1});
    while (runs.size() >= 2 &&
           runs[runs.size() - 2].first == runs[runs.size() - 1].first) {
      runs[runs.size() - 2].second += runs[runs.size() - 1].second;
      runs.pop_back();
      if (runs.back().second % k == 0) {
        runs.pop_back();
      }
    }
  }
  int num = 0;
  for (const auto& r : runs) {
    num += r.second;
  }
  std::cout << solve(runs, num, k, m) << '\n';
}
