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 = 1e5 + 10;
int n, k, m, sz, p;
long long res;
vector<pair<int, int> > v;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (!v.empty() && v.back().first == x) {
      v.back().second++;
      if (v.back().second == k) v.pop_back();
    } else
      v.emplace_back(pair<int, int>(x, 1));
  }
  res = 0;
  sz = v.size();
  for (int i = 0; i < sz; i++) res += (long long)v[i].second;
  if (m == 1 || res == 0) return !printf("%lld\n", res);
  res *= m;
  int st = 0, en = v.size() - 1;
  while (st < en) {
    if (v[st].first != v[en].first) return !printf("%lld\n", res);
    if (v[st].second + v[en].second == k) {
      res -= (long long)(m - 1) * k;
      st++, en--;
      continue;
    }
    if (v[st].second + v[en].second > k) res -= (long long)(m - 1) * k;
    return !printf("%lld\n", res);
  }
  if (st > en) return !printf("%lld\n", 0);
  if (st == en) {
    int ea = v[st].second * m;
    if (v[st].second * m % k == 0)
      return !printf("%lld\n", 0);
    else
      return !printf("%lld\n", res - ea + ea % k);
  }
  return 0;
}
