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;
long long n, k, m, t;
long long matched = 0, head_tail = 0, middle = 0;
deque<pair<long long, long long>> dq;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> t;
    if (dq.empty() || dq.back().first != t) {
      dq.push_back({t, 1});
    } else {
      dq.back().second++;
      if (dq.back().second == k) {
        dq.pop_back();
        middle++;
      }
    }
  }
  while (dq.size() >= 2) {
    if (dq.front().first == dq.back().first &&
        dq.front().second + dq.back().second >= k) {
      head_tail++;
      if (dq.front().second + dq.back().second == k) {
        dq.pop_front();
      }
      dq.pop_back();
    } else {
      break;
    }
  }
  matched += middle * m;
  matched += head_tail * (m - 1);
  if (dq.size() == 1) {
    matched += dq.front().second * m / k;
    if (dq.front().second * m % k == 0) {
      matched += head_tail;
    }
  }
  cout << m * n - matched * k << endl;
  return 0;
}
