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>
const int N = 100005;
int n, k, m, a[N], s[N];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    tot++;
    scanf("%d", &a[tot]);
    if (i == 1 || a[tot] == a[tot - 1])
      s[tot] = s[tot - 1] + 1;
    else
      s[tot] = 1;
    if (s[tot] == k) tot -= k;
  }
  n = tot;
  if (s[n] == n) {
    printf("%lld\n", (long long)n * m % k);
    return 0;
  }
  if (k >= n) {
    printf("%lld\n", (long long)n * m);
    return 0;
  }
  int l = 1, r = n;
  long long ans = 0, tmp = 0;
  while (l <= r) {
    int p = l, q = r + 1;
    while (a[p + 1] == a[l] && p < r) p++;
    while (a[q - 1] == a[l] && q > p + 1) q--;
    if (p + 1 == q) {
      ans += (long long)(r - l + 1) * m % k;
      l = r + 1;
      break;
    }
    int L = p - l + 1 + r - q + 1;
    if (L < k) {
      ans += (long long)(r - l + 1) * m;
      break;
    }
    if (L > k) {
      ans += (long long)(r - l + 1) * m - (long long)k * (m - 1) * (L / k);
      break;
    }
    ans += k;
    tmp += k;
    l = p + 1;
    r = q - 1;
  }
  if (l > r) ans -= tmp;
  printf("%lld\n", ans);
  return 0;
}
