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 main() {
  int n, k, m;
  scanf("%d%d%d", &n, &k, &m);
  deque<pair<int, int> > q;
  int s = n;
  for (int i = 0; i < (int)(n); ++i) {
    int t;
    scanf("%d", &t);
    if (!q.empty() && q.front().first == t)
      ++q.front().second;
    else
      q.push_front(make_pair(t, 1));
    if (q.front().second == k) q.pop_front(), s -= k;
  }
  long long an = (long long)m * s;
  int pr = 0;
  if (m == 1) {
    printf("%lld\n", an);
    return 0;
  }
  while ((int)q.size() > 1) {
    if (q.back().first == q.front().first) {
      int t = q.back().second + q.front().second;
      if (t == k)
        q.pop_front(), q.pop_back(), an -= (long long)(m - 1) * k, pr += k;
      else if (t > k) {
        an -= (long long)(m - 1) * k;
        break;
      } else
        break;
    } else
      break;
  }
  if ((int)q.size() == 1) {
    long long s = (long long)q.front().second * m;
    an = s % k;
    if (an) an += pr;
  }
  printf("%lld\n", an);
}
