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>
static const int MAXN = 1e5 + 4;
int n, k, m;
int a[MAXN];
bool rm[MAXN] = {false};
long long ans;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  ans = (long long)n * m;
  int last = -1, ct = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == last) {
      if (++ct == k) {
        for (int j = i - k + 1; j <= i; ++j) rm[j] = true;
        ct = 0;
        ans -= (long long)m * k;
      }
    } else {
      last = a[i];
      ct = 1;
    }
  }
  int _n = n;
  n = 0;
  for (int i = 0; i < _n; ++i)
    if (!rm[i]) a[n++] = a[i];
  int p = 0, q = n - 1;
  int rp = 0, rq = n - 1;
  while (p <= q) {
    int ct = 0, val = a[p];
    while (p <= q && ct < k && a[p] == val) ++p, ++ct;
    while (p <= q && ct < k && a[q] == val) --q, ++ct;
    if (ct == k) {
      ans -= (long long)(m - 1) * k;
      rp = p;
      rq = q;
    } else {
      break;
    }
  }
  ++rq;
  long long len;
  int sp, sq;
  bool valid = true;
  for (int i = rp; i < rq; ++i)
    if (a[i] != a[rp]) {
      valid = false;
      break;
    }
  if (valid) {
    len = (long long)m * (rq - rp);
    for (sp = rp - 1; sp >= 0; --sp)
      if (a[sp] == a[rp])
        ++len;
      else
        break;
    for (sq = rq; sq < n; ++sq)
      if (a[sq] == a[rp])
        ++len;
      else
        break;
    ans -= (len - len % k);
    len %= k;
    ++sp;
  } else {
    len = -1;
    sp = rp;
    sq = rq;
  }
  last = -1;
  ct = 0;
  for (int i = 0; i < sp; ++i) {
    if (a[i] == last) {
      if (++ct == k) {
        ct = 0;
        ans -= k;
      }
    } else {
      last = a[i];
      ct = 1;
    }
  }
  if (len == -1) {
    last = -1;
    ct = 0;
  } else if (len > 0) {
    if (a[rp] == last) {
      if ((ct += len) >= k) {
        ans -= (ct - ct % k);
        ct %= k;
      }
    } else {
      last = a[rp];
      ct = 1;
    }
  }
  for (int i = sq; i < n; ++i) {
    if (a[i] == last) {
      if (++ct == k) {
        ct = 0;
        ans -= k;
      }
    } else {
      last = a[i];
      ct = 1;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
