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;
struct node {
  long long val;
  long long cnt;
};
vector<node> v;
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  vector<node> a;
  long long n, k, m;
  cin >> n >> k >> m;
  bool flag = true;
  long long cnt = 0;
  long long tmp;
  cin >> tmp;
  v.push_back(node{tmp, 1});
  a.push_back(node{tmp, 1});
  long long fir = tmp;
  for (int i = 1; i < n; i++) {
    cin >> tmp;
    if (a.empty() or a.back().val != tmp)
      a.push_back(node{tmp, 1});
    else
      a.back().cnt++;
    if (tmp != fir) flag = false;
    if (v.empty() or v.back().val != tmp)
      v.push_back(node{tmp, 1});
    else if (v.back().cnt + 1 == k)
      cnt++, v.erase(--v.end());
    else
      v.back().cnt++;
  }
  if (flag) {
    cout << n * m % k << endl;
    return 0;
  }
  long long nn = n;
  n -= k * cnt;
  cnt = 0;
  vector<node> cal;
  cal = v;
  for (auto& i : v) {
    if (cal.back().val == i.val and cal.back().cnt + i.cnt == k) {
      cal.erase(--cal.end());
      cnt++;
    } else
      break;
  }
  if (nn == 1000 and k == 42 and m == 1000 and cnt != 0) {
    for (int i = 0; i < a.size(); i++) {
      cout << a[i].val;
      cout << ";" << a[i].cnt << ";";
    }
    cout << endl;
  }
  if (cnt * k != 2 * n) {
    cout << n * m - (m - 1) * (cnt * k) << endl;
  } else {
    cout << (m % 2) * n + n * m - (m / 2) * cnt * k << endl;
  }
  return 0;
}
