#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int arr[2 * MAX];
int fin[2 * MAX];
int n, K, M;
vector<pair<long long, long long> > Vu;
int main() {
  scanf("%d %d %d", &n, &K, &M);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &fin[i]);
  }
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    if (!Vu.empty() && (Vu.back()).first == fin[i]) {
      (Vu.back()).second++;
      if ((Vu.back().second) == K) {
        Vu.pop_back();
      }
    } else {
      Vu.push_back(make_pair(fin[i], 1));
    }
  }
  long long s = 0;
  for (auto it : Vu) s += it.second;
  if (M == 1 || s == 0) return !printf("%lld\n", s);
  s *= M;
  int st = 0, en = (int)Vu.size() - 1;
  while (st < en) {
    if (Vu[st].first != Vu[en].first) return !printf("%lld\n", s);
    if (Vu[st].second + Vu[en].second == K) {
      s -= (long long)(M - 1) * K;
      st++, en--;
      continue;
    }
    if (Vu[st].second + Vu[en].second > K) s -= (long long)(M - 1) * K;
    return !printf("%lld\n", s);
  }
  if (st > en) return !printf("0\n");
  if (st == en) {
    long long x = Vu[st].second * M;
    if (x % K == 0)
      return !printf("0\n");
    else
      return !printf("%lld\n", s - (x / K) * K);
  }
  return 0;
}
