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 MAXN = 100005;
int a[MAXN];
pair<int, int> sta[MAXN];
int sn;
long long ans;
int main() {
  int n, k, m;
  int l, r;
  int S = 0, M = 0;
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    ++S;
    if (sta[sn].first != x)
      sta[++sn] = {x, 1};
    else {
      sta[sn].second++;
      if (sta[sn].second == k) --sn, S -= k;
    }
  }
  l = 1;
  r = sn;
  while (l < r && sta[l].first == sta[r].first &&
         (sta[l].second + sta[r].second) % k == 0)
    M += sta[l].second + sta[r].second, l++, r--;
  if (m == 1) ans = S;
  if (l < r) {
    if (sta[l].first == sta[r].first)
      M += (sta[l].second + sta[r].second) / k * k;
    ans = 1LL * m * S - 1LL * (m - 1) * M;
  } else if (l == r) {
    if (1LL * sta[l].second * m % k == 0)
      ans = 0;
    else
      ans = 1LL * m * S - 1LL * (m - 1) * M - 1LL * sta[l].second * m / k * k;
  } else
    ans = sn % 2 == 0 ? 0 : S;
  printf("%I64d\n", ans);
  return 0;
}
