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;
int n, k, m, a[N], rep[N];
long long int go(int l, int r) {
  int nl = l, nr = r;
  while (nl < r && a[nl] == a[l]) nl++;
  if (nl == r) return long long int(r - l) * m % k;
  while (nr > l && a[nr - 1] == a[l]) nr--;
  int len1 = nl - l, len2 = r - nr;
  if (len1 + len2 == k) {
    auto ans = go(nl, nr);
    if (ans == 0)
      return 0;
    else
      return k + ans;
  } else if (len1 + len2 < k)
    return long long int(r - l) * m;
  else
    return long long int(r - l) * m - (m - 1) * k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> m;
  bool allEqual = 1;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    allEqual &= (i == 0) || a[i] == a[i - 1];
  }
  if (allEqual) return cout << (long long int)n * m % k << endl, 0;
  int j = 0;
  for (int i = 0; i < (int)(n); i++) {
    a[j] = a[i];
    if (j == 0 || a[j - 1] != a[j])
      rep[j] = 1;
    else
      rep[j] = 1 + rep[j - 1];
    if (rep[j] == k) j -= k;
    j++;
  }
  n = j;
  cout << go(0, n) << endl;
  return 0;
}
