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 node {
  long long x, y;
  node(){};
  node(long long xx, long long yy) { x = xx, y = yy; }
};
long long a[100002];
node b[100002], c[100002];
int main() {
  long long n, k, m, i, j, y, l, r, ab, ans, p;
  scanf("%lld%lld%lld", &n, &k, &m);
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  stack<long long> s, ss;
  s.push(a[0]);
  ss.push(1);
  i = 1;
  while (1) {
    if (i == n) break;
    if (s.empty())
      s.push(a[i]), ss.push(1);
    else if (a[i] == s.top()) {
      y = ss.top(), y++;
      if (y == k)
        s.pop(), ss.pop();
      else
        ss.top()++;
    } else
      s.push(a[i]), ss.push(1);
    i++;
  }
  j = -1;
  while (1) {
    if (s.empty()) break;
    b[++j] = node(s.top(), ss.top()), s.pop(), ss.pop();
  }
  ans = 0;
  for (i = j; i >= 0; i--) c[j - i] = b[i], ans += b[i].y;
  l = 0;
  ab = 0;
  r = j;
  while (1) {
    if (l == r) break;
    if (c[l].x == c[r].x) {
      p = c[l].y + c[r].y;
      if (p == k) {
        ab++, l++, r--;
      } else if (p > k) {
        ab++;
        break;
      } else
        break;
    } else
      break;
  }
  ans *= m;
  ans -= (ab * k * (m - 1));
  if (l == r && j >= 0 && m > 1) {
    ans -= (((c[l].y * m) / k) * k);
    if ((c[l].y * m) % k == 0) {
      if (c[0].x == c[j].x) {
        p = c[0].y + c[j].y;
        if (p >= k) ans -= (ab * k);
      }
    }
  }
  printf("%lld\n", ans);
}
