#include <bits/stdc++.h>
using namespace std;
int k;
int s[100009];
int c[100009];
int compress(int n) {
  int m = 0;
  for (int i = 0; i < n; i++) {
    c[m] = (m && s[m - 1] == s[i]) ? c[m - 1] + 1 : 1;
    s[m++] = s[i];
    if (c[m - 1] == k) m -= k;
  }
  return m;
}
int main() {
  int n, m;
  scanf("%d %d %d", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", s + i);
  }
  n = compress(n);
  if (n == 0) {
    cout << 0;
    return 0;
  }
  for (int i = 0, j = n - 1; i <= j;) {
    if (s[i] != s[j]) {
      cout << (long long)i + (long long)(n - 1 - j) +
                  (long long)m * (long long)(j - i + 1);
      return 0;
    }
    int ii = i, jj = j;
    while (ii <= j && s[ii] == s[i]) ii++;
    if (ii > j) {
      long long tmp = ((long long)m * (long long)(j - i + 1)) % (long long)k;
      if (tmp == 0) {
        for (int t = j + 1; t < n; t++) {
          s[t - (j + 1) + i] = s[t];
        }
        cout << compress(n - (j - i + 1));
      } else {
        cout << (long long)i + (long long)(n - 1 - j) + tmp;
      }
      return 0;
    }
    while (s[jj] == s[j]) jj--;
    int tmp = ii - i + j - jj;
    if (tmp % k) {
      long long ans = (long long)ii + (long long)(n - 1 - jj);
      ans += (long long)(tmp % k) * ((long long)(m - 1));
      ans += (long long)(jj - ii + 1) * (long long)m;
      cout << ans;
      return 0;
    }
    i = ii;
    j = jj;
  }
}
