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 double eps = 1e-8;
int dcmp(double x) {
  if (fabs(x) <= eps) return 0;
  return (x > 0) ? 1 : -1;
};
void file() {
  freopen("out.txt", "r", stdin);
  freopen("out1.txt", "w", stdout);
}
namespace Solver {
const int maxn = 100000 + 10;
int n, k, m;
int v[maxn];
int p = 0;
int b[maxn], c[maxn];
void solve() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (v[i] != b[p])
      b[++p] = v[i], c[p] = 1;
    else {
      c[p]++;
      if (c[p] == k) p--, cnt += k;
    }
  }
  if (p == 1) {
    cnt = m * c[p] / k * k;
  } else {
    if (p != 0) {
      int r = p, l = 1;
      for (;;) {
        if (b[l] != b[r]) break;
        int len = c[l] + c[r];
        l++, r--;
        if (l > p) {
          if (m & 1)
            printf("%d\n", n);
          else
            puts("0");
          return;
        }
        if (len < k) break;
        if (len % k == 0)
          cnt += (m - 1) * (len);
        else {
          cnt += (m - 1) * (len / k * k);
          break;
        }
      }
    }
  }
  printf("%lld\n", n * m - cnt);
}
}  // namespace Solver
int main() {
  Solver::solve();
  return 0;
}
