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;
long long n, k, m;
long long teamrem = 0;
struct st {
  deque<pair<int, int> > a;
  int 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()) > 1010100 / 2) a.pop_back();
    while (((int)o.a.size()) > 1010100 / 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;
}
