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 + 5;
long long n, k, m;
int a[N], s[N];
int main() {
  memset(a, -1, sizeof(a));
  memset(s, -1, sizeof(s));
  scanf("%d", &n), scanf("%d", &k), scanf("%d", &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int p = 1;
  int tot = 0;
  while (p <= n) {
    int cnt = 0;
    while (a[p] == a[p + 1] && cnt < k) p++, cnt++;
    if (cnt != k) s[++tot] = a[p];
    p++;
  }
  int l = 0, r = tot + 1;
  int t = 0;
  int L, R;
  while (s[++l] == s[--r] && l < r) {
    int cnt = 2;
    while (l < r && s[l] == s[l + 1] && cnt < k) l++, cnt++;
    while (l < r && s[r] == s[r - 1] && cnt < k) r--, cnt++;
    if (cnt == k)
      t++, L = l, R = r;
    else
      break;
  }
  bool flag = false;
  while (l < r && s[l] == s[l + 1] && s[r] == s[r - 1]) l++, r--;
  if (l >= r) flag = true;
  int dx = R - L - 1;
  if (dx < 0) {
    cout << tot % k;
    return 0;
  }
  int md = dx * m % k;
  if (flag)
    cout << md ? md + tot - dx : 0;
  else
    cout << m * (tot - t * k) + t * k;
  return 0;
}
