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;
struct task {
  int a, b;
};
int n, i, k, m, x, v, sum = 0;
deque<task> q;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (q.empty() || q.back().a != x)
      q.push_back((task){x, 1});
    else {
      q.back().b++;
      if (q.back().b == k) {
        q.pop_back();
        n -= k;
      }
    }
  }
  while (q.size() > 1) {
    if (q.front().a == q.back().a && q.front().b + q.back().b >= k) {
      if (q.back().b > k)
        q.back().b - k;
      else {
        v = k - q.back().b;
        q.pop_back();
        if (q.front().b == v)
          q.pop_front();
        else
          q.front().b -= v;
      }
    } else
      break;
  }
  if (q.size() == 1) {
    if (1LL * q.back().b * m % k == 0)
      printf("0");
    else
      printf("%I64d\n", 1LL * q.back().b * m % k + n - q.back().b);
  } else {
    sum = 0;
    while (!q.empty()) {
      sum += q.front().b;
      q.pop_front();
    }
    printf("%I64d\n", 1LL * sum * m + n - sum);
    if (n == 1000 && m == 2) printf("#%I64d\n", 1LL * sum * m + n - sum);
  }
  return 0;
}
