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 = 100010;
long long n, m, k;
long long a[MAXN];
long long b[MAXN];
long long cnt[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  bool single_color = true;
  for (long long i = 1; i < n; i++)
    if (a[i] != a[i + 1]) single_color = false;
  if (single_color) {
    cout << n * m % k << endl;
    return 0;
  }
  long long p, q, tmpp, tmpq, count;
  long long ans;
  long long Out_come;
  for (long long i = 1; i <= n; i++) {
    b[++b[0]] = a[i];
    if (b[0] > 1 && b[b[0]] == b[b[0] - 1])
      cnt[b[0]] = cnt[b[0] - 1] + 1;
    else
      cnt[b[0]] = 1;
    if (cnt[b[0]] >= k) b[0] -= k;
  }
  p = 1;
  q = b[0];
  ans = 0;
  while (b[p] == b[q] && p < q) {
    count = 0;
    tmpp = p;
    tmpq = q;
    while (count < k && tmpp < tmpq && b[tmpp] == b[p]) tmpp++, count++;
    while (count < k && tmpp < tmpq && b[tmpq] == b[q]) tmpq--, count++;
    if (count == k)
      ans += k, p = tmpp, q = tmpq;
    else
      break;
  }
  Out_come = (q - p + 1) * m + ans;
  bool boo = true;
  for (long long i = p; i <= q; i++)
    if (b[i] != b[p]) boo = false;
  if (boo) {
    long long cur = (q - p + 1) * m;
    if (cur % k == 0)
      Out_come = 0;
    else
      Out_come = cur % k + ans;
  }
  cout << Out_come << endl;
  return 0;
}
