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<int> a, num;
int main() {
  int n, m, k, max1 = 0, sum, b[100000];
  cin >> n >> k >> m;
  sum = 2 * n;
  cin >> b[0];
  a.push_back(1);
  num.push_back(b[0]);
  for (int i = 1; i < n; i++) {
    cin >> b[i];
    if (num[num.size() - 1] == b[i]) {
      if (a[a.size() - 1] < k - 1)
        a[a.size() - 1]++;
      else {
        sum -= k;
        a.pop_back();
        num.pop_back();
      }
    } else {
      a.push_back(1);
      num.push_back(b[i]);
    }
  }
  int l = a.size(), d = 0;
  for (int i = 0; i < n; i++) {
    if (num[num.size() - 1] == b[i]) {
      if (a[a.size() - 1] < k - 1)
        a[a.size() - 1]++;
      else {
        sum -= k;
        if (a.size() == l) {
          d += a[a.size() - 1] + 1;
        }
        a.pop_back();
        num.pop_back();
        l--;
      }
    } else {
      a.push_back(1);
      num.push_back(b[i]);
    }
  }
  if (a.size() == 1 && m >= k)
    cout << m - (m / k) * k;
  else {
    if (sum == 0)
      cout << 0;
    else
      cout << (sum - d) * m / 2 + d;
  }
  return 0;
}
