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;
const int maxN(210);
const int inf(1e9);
const long long mod(1e9 + 7);
template <typename T1>
inline void in(T1 &a1) {
  cin >> a1;
}
template <typename T1, typename T2>
inline void in(T1 &a1, T2 &a2) {
  cin >> a1 >> a2;
}
template <typename T1, typename T2, typename T3>
inline void in(T1 &a1, T2 &a2, T3 &a3) {
  cin >> a1 >> a2 >> a3;
}
vector<int> a;
vector<pair<int, int> > seg[40], res, tp;
int k;
long long merge(vector<pair<int, int> > x, vector<pair<int, int> > y,
                vector<pair<int, int> > &z) {
  z.clear();
  if (x.empty()) {
    z = y;
    return 0;
  }
  if (y.empty()) {
    z = x;
    return 0;
  }
  long long diff = 0;
  int i, j, n = ((int)(x.size())), m = ((int)(y.size()));
  for (i = n - 1, j = 0; i >= 0 && j < m; i--, j++) {
    if (x[i].first != y[j].first) break;
    int &d = x[i].second;
    d += y[j].second, y[j].second = 0;
    if (d >= k) diff += k, d -= k;
    if (d != 0) break;
  }
  for (i = 0; i < n; i++)
    if (x[i].second > 0) z.push_back(x[i]);
  for (j = 0; j < m; j++)
    if (y[j].second > 0) z.push_back(y[j]);
  return diff;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long ans = 0;
  int i, j, n, m;
  in(n, k, m);
  for (i = 0; i < n; i++) {
    int x;
    in(x), a.push_back(x);
  }
  for (i = 0; i < n; i = j) {
    for (j = i; j < n && a[i] == a[j]; j++)
      ;
    seg[0].push_back({a[i], (j - i) % k});
  }
  for (i = 1; (1 << i) <= m; i++) {
    merge(seg[i - 1], seg[i - 1], seg[i]);
    if (((int)(seg[i - 1].size())) < ((int)(seg[j = i].size()))) break;
  }
  if (j < i) {
    for (i = 0; (1 << i) <= m; i++) {
      if (!(m & (1 << i))) continue;
      merge(res, seg[i], res);
    }
    for (auto &e : res) ans += e.second;
  } else {
    --j;
    for (i = 0; i < j; i++) {
      if (!(m & (1 << i))) continue;
      merge(res, seg[i], res);
    }
    for (auto &e : res) ans += e.second;
    int _m = m / (1 << j);
    ans += 1LL * ((int)(seg[j].size())) * _m;
    ans -= merge(seg[j], seg[j], seg[j + 1]) * (_m - 1);
    tp.clear();
    for (i = 0; i < _m; i++) {
      merge(tp, seg[j], tp);
      if (((int)(res.size())) + ((int)(seg[j].size())) < ((int)(tp.size())))
        break;
    }
    ans -= merge(res, tp, res);
  }
  printf("%lld\n", ans);
}
