#include <bits/stdc++.h>
using namespace std;
deque<pair<int, int>> d;
int marime() {
  int ans(0);
  for (auto i : d) ans += i.second;
  return ans;
}
int main() {
  int n, k, m;
  cin >> n >> k >> m;
  int q;
  for (int i(1); i <= n; i++) {
    int c;
    cin >> c;
    if (i == 1) q = c;
    if (!d.empty() && d.front().first == c)
      d.front().second++;
    else
      d.push_front({c, 1});
    if (!d.empty() && d.front().second == k) d.pop_front();
  }
  if (m == 1) {
    cout << marime();
    return 0;
  }
  int marime_init = marime();
  while (d.size() >= 2 && d.front().first == d.back().first) {
    if (d.front().second + d.back().second < k) break;
    int rms = d.front().second + d.back().second - k;
    d.pop_front();
    if (!rms)
      d.pop_back();
    else
      d.back().second = rms;
  }
  if (d.empty()) {
    cout << (m & 1 ? marime_init : 0) << '\n';
    assert(n != 1000 || k != 42 || q != 8);
    return 0;
  }
  if (d.size() == 1) {
    long long x = d.front().second;
    x *= m;
    x %= k;
    if (x == 0)
      cout << 0;
    else {
      cout << marime_init + x - d.front().second;
    }
    return 0;
  }
  cout << 1ll * marime_init + 1ll * (m - 1) * marime() << '\n';
  return 0;
}
