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;
const int N = 500010;
int n, k, m;
int a[N];
long long ans;
struct Node {
  vector<int> l, r;
  long long len;
} ori;
int col[N], Count[N], tot;
inline Node join(const Node &a, const Node &b) {
  tot = 0;
  long long len = a.len + b.len;
  for (int i = 0; i < a.r.size(); i++) {
    if (i == 0 || a.r[i] != col[tot]) {
      col[++tot] = a.r[i];
      Count[tot] = 1;
    } else
      Count[tot]++;
    while (Count[tot] >= k) {
      Count[tot] -= k;
      len -= k;
      if (Count[tot] == 0) tot--;
    }
  }
  for (int i = 0; i < b.l.size(); i++) {
    if (b.l[i] != col[tot]) {
      col[++tot] = b.l[i];
      Count[tot] = 1;
    } else
      Count[tot]++;
    while (Count[tot] >= k) {
      Count[tot] -= k;
      len -= k;
      if (Count[tot] == 0) tot--;
    }
  }
  Node ret;
  ret.len = len;
  if (a.len < 2 * n) {
    int C = 0;
    int up;
    if (ret.len < 2 * n)
      up = ret.len;
    else
      up = n;
    for (int i = 1; i <= tot; i++) {
      for (int j = 1; j <= Count[i]; j++) {
        ret.l.push_back(col[i]);
        C++;
        if (C == up) break;
      }
      if (C == up) break;
    }
  } else
    ret.l = a.l;
  if (b.len < 2 * n) {
    int C = 0;
    int up;
    if (ret.len < 2 * n)
      up = ret.len;
    else
      up = n;
    for (int i = tot; i > 0; i--) {
      for (int j = 1; j <= Count[i]; j++) {
        ret.r.push_back(col[i]);
        C++;
        if (C == up) break;
      }
      if (C == up) break;
    }
    reverse(ret.r.begin(), ret.r.end());
  } else
    ret.r = b.r;
  return ret;
}
Node Pow(int x) {
  if (x == 1) {
    return ori;
  }
  Node ret = Pow(x >> 1);
  ret = join(ret, ret);
  if (x & 1) ret = join(ret, ori);
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  bool flag = true;
  for (int i = 2; i <= n; i++)
    if (a[i] != a[i - 1]) flag = false;
  if (flag) {
    printf("%I64d\n", 1ll * n * m % k);
    return 0;
  }
  vector<int> tmp;
  tot = 0;
  int len = n;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || a[i] != col[tot]) {
      col[++tot] = a[i];
      Count[tot] = 1;
    } else
      Count[tot]++;
    while (Count[tot] >= k) {
      Count[tot] -= k;
      len -= k;
      if (Count[tot] == 0) tot--;
    }
  }
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= Count[i]; j++) tmp.push_back(col[i]);
  ori.l = ori.r = tmp;
  ori.len = len;
  Node t = Pow(m);
  printf("%I64d\n", t.len);
  return 0;
}
