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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
int n, sz, reps;
int a[MAXN];
pair<int, int> b[MAXN];
int nb;
void run() {
  scanf("%d%d%d", &n, &sz, &reps);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  nb = 0;
  for (int i = (0); i < (n); ++i) {
    if (nb > 0 && b[nb - 1].first == a[i])
      ++b[nb - 1].second;
    else
      b[nb++] = make_pair(a[i], 1);
    if (nb > 0 && b[nb - 1].second == sz) --nb;
  }
  int matchcnt = 0, matchsum = 0;
  while (matchcnt < nb && b[matchcnt].first == b[nb - matchcnt - 1].first &&
         b[matchcnt].second + b[nb - matchcnt - 1].second == sz)
    ++matchcnt, matchsum += sz;
  int bsum = 0;
  for (int i = (0); i < (nb); ++i) bsum += b[i].second;
  if (reps == 1) {
    printf("%d\n", bsum);
    return;
  }
  if (matchcnt == nb) {
    printf("%d\n", (reps % 2) * bsum);
    return;
  }
  assert(2 * matchcnt < nb);
  if (2 * matchcnt + 1 == nb) {
    int bmid = (long long)reps * b[matchcnt].second % sz;
    printf("%d\n", bmid == 0 ? 0 : bmid + matchsum);
    return;
  }
  if (b[matchcnt].first == b[nb - matchcnt - 1].first &&
      b[matchcnt].second + b[nb - matchcnt - 1].second >= sz)
    matchsum += sz;
  printf("%lld\n", (long long)reps * bsum - (long long)(reps - 1) * matchsum);
}
int main() {
  run();
  return 0;
}
