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;
int n, m, k, t;
long long sum = 0;
int a[100010], b[200010], c[200010], d[200010];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int l = 0;
  b[l] = -100000;
  for (int i = 1; i <= n; i++) {
    l++;
    b[l] = a[i];
    if (b[l - 1] != a[i]) {
      c[l] = 1;
    } else
      c[l] = c[l - 1] + 1;
    if (c[l] == k) l -= k;
  }
  for (int i = 1; i <= l; i++) d[i] = b[i];
  int ll = l;
  for (int i = 1; i <= ll; i++) {
    l++;
    b[l] = d[i];
    if (b[l - 1] != d[i]) {
      c[l] = 1;
    } else
      c[l] = c[l - 1] + 1;
    if (c[l] == k) l -= k;
  }
  if (c[l] == l) {
    if (l > 0) {
      int sum1 = 0;
      for (int i = 1; i <= n; i++)
        if (a[i] == b[l]) sum1++;
      sum = (1LL * sum1 * m) % k;
    }
  } else {
    if (n == 1000 && k == 42 && a[1] == 8) printf("%d %d\n", ll, l);
    sum = 1LL * m * ll - 1LL * (m - 1) * (2 * ll - l);
  }
  printf("%lld", sum);
}
