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 long double pi = acosl(-1);
const int maxn = 100010;
const long long mod = 1e6 + 3;
const int inf = 1e9;
int n, k, m;
int a[maxn];
deque<pair<int, int> > vec;
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int s = n;
  for (int i = 0; i < n; i++) {
    if (!vec.empty() && vec.back().first == a[i]) {
      vec.back().second++;
    } else {
      vec.push_back({a[i], 1});
    }
    if (!vec.empty() && vec.back().second == k) {
      vec.pop_back();
      s -= k;
    }
  }
  long long sum = (long long)s * m;
  if (m == 1) {
    cout << sum << endl;
    return 0;
  }
  long long pr = 0;
  while (vec.size() >= 2 && vec[0].first == vec.back().first) {
    if (vec[0].second + vec.back().second == k) {
      vec.pop_back();
      vec.pop_front();
      sum -= (long long)k * (m - 1);
      pr += k;
    } else if (vec[0].second + vec.back().second > k) {
      int tmp = vec[0].second + vec.back().second - k;
      vec.back().second = 0;
      vec[0].second = tmp;
      sum -= (long long)k * (m - 1);
      break;
    } else {
      break;
    }
  }
  if (vec.size() == 1) {
    long long tmp = (long long)vec[0].second * m;
    sum = tmp % k;
    if (sum) sum += pr;
  }
  cout << sum << endl;
  return 0;
}
