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;
int n, k, m;
int A[100010];
vector<pair<int, int> > V;
void Merge(vector<pair<int, int> > &A, vector<pair<int, int> > B) {
  for (pair<int, int> e : B) {
    if (((int)(A).size()) == 0 || A.back().first != e.first)
      A.push_back(e);
    else {
      A.back().second += e.second;
      if (A.back().second >= k) A.back().second -= k;
      if (A.back().second == 0) A.pop_back();
    }
  }
}
long long fix(vector<pair<int, int> > &W) {
  if (((int)(W).size()) < 4 * n) return 0;
  vector<pair<int, int> > temp = W;
  long long res = 0;
  for (int i = 0; i < 2 * n; i++) temp.push_back(W[i]);
  for (int i = 2 * n; i < ((int)(W).size()) - 2 * n; i++) res += W[i].second;
  for (int i = 2 * n; i; i--) temp.push_back(W[((int)(W).size()) - i]);
  return res;
}
void solve() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", A + i);
  vector<pair<int, int> > X;
  for (int i = 1; i <= n; i++) {
    if (((int)(X).size()) == 0 || X.back().first != A[i])
      X.push_back(pair<int, int>(A[i], 1));
    else {
      X.back().second += 1;
      if (X.back().second == k) X.pop_back();
    }
  }
  long long ans = 0;
  vector<pair<int, int> > now;
  while (m) {
    if (m & 1) {
      Merge(now, X);
      ans += fix(now);
    }
    Merge(X, X);
    m >>= 1;
  }
  for (pair<int, int> e : now) ans += e.second;
  printf("%lld\n", ans);
}
int main() {
  int Tc = 1;
  for (int tc = 1; tc <= Tc; tc++) {
    solve();
  }
  return 0;
}
