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>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
template <typename T>
inline void read(T &x) {
  bool f;
  char ch;
  f = 0;
  x = 0;
  ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  if (f) x = -x;
}
template <typename T>
inline void Max(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
inline void Min(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
inline T Abs(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
const double pi = (double)acos(-1.0);
const int MOD = (int)1e9 + 7;
const int INF = (int)0x3f3f3f3f;
const long long LINF = (long long)INF << 32 | INF;
const int SINF = (unsigned)~0 >> 1;
const long long SLINF = (unsigned long long)(-1) >> 1;
const double DINF = (double)1e50;
const double eps = (double)1e-8;
const int maxn = (int)2000 + 20;
const int maxm = (int)1e5 + 20;
const int maxk = (int)5e2 + 20;
inline int sig(double x) { return x < -eps ? -1 : x > eps; }
int n, k, m;
int a[maxn], b[maxn];
void work() {
  read(n), read(k), read(m);
  for (int i = 1; i <= n; i++) read(a[i]);
  int p = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[p]) {
      a[++p] = a[i];
      b[p] = 1;
    } else {
      b[p]++;
      if (b[p] == k) p--;
    }
  }
  if (p == 0) {
    puts("0");
    return;
  }
  int tot = 0;
  for (int i = 1; i <= p; i++) tot += b[i];
  int l = 1, r = p, acc = 0;
  while (l < r) {
    if (a[l] == a[r]) {
      if (b[l] + b[r] < k) {
        long long ans = (long long)tot * m - (long long)acc * (m - 1);
        cout << ans << endl;
        return;
      }
      if (b[l] + b[r] > k) {
        acc += k;
        long long ans = (long long)tot * m - (long long)acc * (m - 1);
        cout << ans << endl;
        return;
      }
      acc += k;
    } else {
      long long ans = (long long)tot * m - (long long)acc * (m - 1);
      cout << ans << endl;
      return;
    }
    l++, r--;
  }
  int temp = (long long)b[l] * m % k;
  if (temp) {
    cout << tot - b[l] + temp << endl;
  } else {
    puts("0");
  }
}
int main() {
  work();
  return 0;
}
