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;
vector<pair<long long, long long> > v;
int main() {
  long long n, i, j, tmp, k, m, rm = 0;
  scanf("%lld", &n);
  scanf("%lld", &k);
  scanf("%lld", &m);
  for (i = 0; i < n; i++) {
    scanf("%lld", &tmp);
    if (!v.size()) {
      v.push_back(make_pair(tmp, 1));
      continue;
    }
    if (v[v.size() - 1].first == tmp) {
      v[v.size() - 1].second++;
      if (v[v.size() - 1].second == k) v.pop_back(), rm += (m * k);
      continue;
    }
    v.push_back(make_pair(tmp, 1));
  }
  bool f = 0;
  n = v.size();
  for (i = 0; i < ((n - 1) / 2); i++) {
    if (v[i].second + v[v.size() - 1 - i].second == k)
      rm += ((m - 1) * k);
    else {
      if (v[i].second + v[v.size() - 1 - i].second > k) rm += ((m - 1) * k);
      f = 1;
      break;
    }
  }
  long long ans = (m * n) - rm;
  if (!f && n & 1) ans = ((v[n / 2].second * m) % k);
  printf("%lld\n", ans);
  return 0;
}
