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 Dim = 3e5 + 5;
long long v[Dim], aux[Dim], lg[Dim];
long long n, m, k, nr, nre;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  for (int i = 1; i <= n; ++i) {
    aux[++nre] = v[i];
    if (aux[nre] == aux[nre - 1]) {
      lg[nre] = lg[nre - 1] + 1;
    } else {
      lg[nre] = 1;
    }
    if (lg[nre] == k) {
      while (lg[nre] != 1) --nre;
      --nre;
    }
  }
  n = nre;
  long long fi = 0, pas = 0;
  long long l = 1, r = n, ans = 0;
  long long L = 1, R = nre;
  while (aux[L] == aux[R] && L != R) {
    long long l = L, r = R, cnt = 0;
    while (aux[L] == aux[l] && l < r && cnt < k) ++l, ++cnt;
    while (aux[R] == aux[r] && l < r && cnt < k) --r, ++cnt;
    if (cnt == k)
      L = l, R = r, ans += k;
    else
      break;
  }
  bool ok = true;
  for (int i = l + 1; i <= r; ++i) {
    if (aux[i] != aux[i - 1]) {
      ok = false;
      break;
    }
  }
  n = (R - L + 1);
  if (ok) {
    long long sol = (n * m) % k;
    if (sol != 0) {
      sol += ans;
    }
    cout << sol;
  } else {
    cout << n * m + ans;
  }
  return 0;
}
