#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, k, m;
deque<pair<int, int> > init;
void show(deque<pair<int, int> > &cur) {
  for (auto it = cur.begin(); it != cur.end(); it++) {
    cerr << it->first << " " << it->second << endl;
  }
}
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (init.empty()) {
      init.push_back(pair<int, int>(a, 1));
    } else {
      pair<int, int> cur = init.back();
      init.pop_back();
      if (cur.first == a) {
        cur.second++;
        cur.second %= k;
        if (cur.second) init.push_back(cur);
      } else {
        init.push_back(cur);
        init.push_back(pair<int, int>(a, 1));
      }
    }
  }
  deque<pair<int, int> > mid = init;
  deque<pair<int, int> > Left, Right;
  while (mid.size() >= 2 && mid.front().first == mid.back().first &&
         mid.front().second + mid.back().second >= k) {
    pair<int, int> left = mid.front();
    mid.pop_front();
    pair<int, int> right = mid.back();
    mid.pop_back();
    int tmp = (right.second + left.second) % k;
    int cn_right = min(right.second, tmp);
    int cn_left = tmp - cn_right;
    if (right.second - cn_right != 0)
      Right.push_front(pair<int, int>(right.first, right.second - cn_right));
    if (left.second - cn_left != 0)
      Left.push_back(pair<int, int>(left.first, left.second - cn_left));
    right.second = cn_right;
    left.second = cn_left;
    if (left.second != 0) mid.push_front(left);
    if (right.second != 0) mid.push_back(right);
  }
  n = 0;
  for (auto it = init.begin(); it != init.end(); it++) {
    n += it->second;
  }
  int last = 0;
  for (auto it = mid.begin(); it != mid.end(); it++) {
    last += it->second;
  }
  long long ans;
  if (mid.size() != 1) {
    ans = (long long)last * m + n - last;
  } else {
    pair<int, int> at = mid.front();
    at.second = ((long long)at.second * m) % k;
    if (at.second) {
      if (Left.empty())
        Left.push_back(at);
      else
        Right.push_front(at);
    }
    while (!Right.empty() && !Left.empty()) {
      pair<int, int> left = Left.back();
      Left.pop_back();
      pair<int, int> right = Right.front();
      Right.pop_front();
      if (left.first == right.first) {
        left.second += right.second;
        left.second %= k;
        if (left.second) Left.push_back(left);
      } else {
        Left.push_back(left);
        Left.push_back(right);
      }
    }
    ans = 0;
    for (auto it = Left.begin(); it != Left.end(); it++) {
      ans += it->second;
    }
  }
  cout << ans << endl;
  return 0;
}
