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 N = 1e5 + 10;
const int LOGM = 30 + 10;
int k;
vector<pair<int, int> > *merge(vector<pair<int, int> > &a,
                               vector<pair<int, int> > &b) {
  vector<pair<int, int> > *ans = new vector<pair<int, int> >(a);
  for (int i = 0; i < b.size(); i++) {
    if (!ans->empty()) {
      if (ans->back().second == b[i].second) {
        ans->back().first = (ans->back().first + b[i].first) % k;
        if (ans->back().first == 0) ans->pop_back();
      } else
        ans->push_back(b[i]);
    } else
      ans->push_back(b[i]);
  }
  return ans;
}
int main() {
  int n, m, temp, now = 1, last;
  long long int ans = 0;
  vector<pair<int, int> > *v[LOGM], a, *s = new vector<pair<int, int> >;
  scanf("%d%d%d%d", &n, &k, &m, &last);
  v[0] = new vector<pair<int, int> >;
  for (int i = 1; i < n; i++) {
    scanf("%d", &temp);
    if (temp != last) {
      now %= k;
      if (now != 0) v[0]->push_back(make_pair(now, last));
      last = temp;
      now = 1;
    } else
      now++;
  }
  v[0]->push_back(make_pair(last, now));
  for (int i = 1; (1 << i) <= m; i++) v[i] = merge(*v[i - 1], *v[i - 1]);
  for (int i = 0; (1 << i) <= m; i++)
    if (m & (1 << i)) s = merge(*s, *v[i]);
  a = *s;
  for (int i = 0; i < a.size(); i++) ans += a[i].first;
  printf("%lld\n", ans);
}
