#include <bits/stdc++.h>
using namespace std;
long long n, k, m;
struct st {
  deque<pair<int, int> > a;
  long long rem;
  st& operator+=(st o) {
    rem += o.rem;
    while (1) {
      if (!((int)a.size()) or !((int)o.a.size())) break;
      if (a.back().first != o.a.front().first) break;
      long long t = a.back().second + o.a.front().second;
      rem += t / k;
      t %= k;
      if (t)
        a.back().second = t;
      else
        a.pop_back();
      o.a.pop_front();
    }
    while (((int)a.size()) > 5010100 / 2) a.pop_back();
    while (((int)o.a.size()) > 5010100 / 2) o.a.pop_front();
    while (((int)o.a.size())) a.push_back(o.a.front()), o.a.pop_front();
    return *this;
  }
};
st x, ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> m;
  for (int i = -1; ++i < n;) {
    int u;
    cin >> u;
    if (((int)x.a.size()) == 0 or x.a.back().first != u) x.a.push_back({u, 0});
    ++x.a.back().second;
    if (x.a.back().second >= k) x.a.pop_back(), x.rem++;
  }
  for (int i = m; i > 0; i >>= 1) {
    if (i & 1) ans += x;
    x += x;
  }
  cout << n * m - ans.rem * k;
  return 0;
}
