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