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 P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 1e6 + 10;
int n, m, k, len;
int a[N], L[N], R[N], b[N], vis[N];
queue<int> q;
void del(int first) {
  if (L[first]) R[L[first]] = R[first];
  if (R[first] <= len) L[R[first]] = L[first];
  vis[first] = 1;
}
void merge(int first, int second) {
  b[first] += b[second];
  del(second);
}
int solve(int n) {
  len = n;
  for (int i = 1; i <= n; ++i)
    L[i] = i - 1, R[i] = i + 1, b[i] = 1, vis[i] = 0, q.push(i);
  while (q.size()) {
    int u = q.front();
    q.pop();
    if (vis[u]) continue;
    while (1) {
      if (L[u] && a[L[u]] == a[u])
        merge(u, L[u]);
      else if (R[u] <= n && a[R[u]] == a[u])
        merge(u, R[u]);
      else
        break;
    }
    if (b[u] >= k) {
      b[u] %= k;
      if (!b[u]) del(u);
      if (L[u]) q.push(L[u]);
      if (R[u] <= n) q.push(R[u]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) ans += b[i];
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  set<int> s;
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), s.insert(a[i]);
  if (s.size() == 1) return printf("%d\n", n * m % k), 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= 5; ++j) a[i + j * n] = a[i];
  for (int i = 1; i <= 6; ++i) {
    int t = solve(i * n);
    if (i == m) return printf("%d\n", t), 0;
  }
  int u = solve(5 * n), v = solve(6 * n), d = v - u;
  printf("%d\n", u + (m - 5) * d);
}
