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 n, k, m;
long long a[100005];
pair<long long, long long> st[100005];
int main() {
  scanf("%I64d %I64d %I64d", &n, &k, &m);
  long long t = 0;
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    if (t == 0)
      st[t++] = pair<long long, long long>(a[i], 1);
    else {
      pair<long long, long long> p = st[t - 1];
      if (p.first == a[i]) {
        t--;
        p.second++;
        if (p.second != k) st[t++] = p;
      } else
        st[t++] = pair<long long, long long>(a[i], 1);
    }
  }
  long long cnt = 0, s = 0, res = 0;
  for (long long i = 0; i < t / 2; i++) {
    if (st[i].first == st[t - 1 - i].first) {
      if (st[i].second + st[t - 1 - i].second >= k) {
        res++;
        if (st[i].second + st[t - 1 - i].second == k) {
          cnt++;
          continue;
        }
      }
    }
    break;
  }
  for (long long i = 0; i < t; i++) s += st[i].second;
  if (cnt >= (t + 1) / 2)
    if (m % 2 == 0)
      printf("0\n");
    else
      printf("%I64d\n", s);
  else if (t % 2 == 1 && cnt == t / 2)
    if ((m * st[cnt].second) % k == 0)
      printf("0\n");
    else
      printf("%I64d\n", s - st[cnt].second + (m * st[cnt].second) % k);
  else
    printf("%I64d\n", m * s - (m - 1) * res * k);
  return 0;
}
