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;
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;
  for (int i(1); i <= n; i++) {
    int c;
    cin >> 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';
    return 0;
  }
  if (d.size() == 1) {
    long long x = d.front().second;
    x *= m;
    x %= k;
    if (x == 0)
      cout << 0;
    else {
      cout << n + x - d.front().second;
    }
    return 0;
  }
  cout << 1ll * marime_init * m - 1ll * (m - 1) * (marime_init - marime())
       << '\n';
  return 0;
}
