#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
struct node {
  int x, y;
  node() {}
  node(int x, int y) : x(x), y(y) {}
} a[N];
int n, k, m, nn;
int c[N];
long long solve(int l, int r) {
  int i, j;
  if (l > r) return 0;
  if (c[l] != c[r]) return 1ll * (r - l + 1) * m;
  for (i = l; i < r && c[i] == c[i + 1]; i++)
    ;
  for (j = r; j > l && c[j] == c[j - 1]; j--)
    ;
  if (i == r) return 1ll * m * (r - l + 1) % k;
  int len = i - l + 1 + r - j + 1;
  long long s;
  len = len % k;
  if (len == 0) {
    s = solve(i + 1, j - 1);
    if (!s)
      return 0;
    else
      return s + 1ll * k;
  }
  return 1ll * (m - 1) * len + 1ll * (j - i - 1) * m + 1ll * (i - l + 1) % k +
         1ll * (r - j + 1) % k;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    if (c[i] == a[nn].x)
      a[nn].y++;
    else
      a[++nn] = node(c[i], 1);
    if (a[nn].y == k) nn--;
  }
  if (!nn) {
    printf("%d\n", nn);
    return 0;
  }
  n = 0;
  for (int i = 1; i <= nn; i++) {
    while (a[i].y) {
      a[i].y--;
      c[++n] = a[i].x;
    }
  }
  if (m == 1) {
    printf("%d\n", n);
    return 0;
  }
  printf("%I64d\n", solve(1, n));
  return 0;
}
