#include <bits/stdc++.h>
using namespace std;
const int N = 200020;
long long total;
int k;
deque<int> trata(deque<int> &d) {
  deque<pair<int, int> > at;
  int cnt = 0;
  for (int i = 0; i < d.size(); i++) {
    if (at.empty()) {
      at.emplace_back(d[i], 1);
      cnt = 1;
    } else if (at.back().first == d[i]) {
      at.emplace_back(d[i], cnt + 1);
      cnt++;
    } else {
      at.emplace_back(d[i], 1);
      cnt = 1;
    }
    if (cnt == k) {
      for (int j = 0; j < k; j++) at.pop_back();
      total -= k;
      if (at.empty())
        cnt = 0;
      else
        cnt = at.back().second;
    }
  }
  deque<int> at2;
  for (int i = 0; i < at.size(); i++) at2.push_back(at[i].first);
  return at2;
}
int a[N];
int main(void) {
  int n, m;
  scanf("%d %d %d", &n, &k, &m);
  set<int> s;
  deque<int> deq;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    deq.push_back(a[i]);
  }
  deq = trata(deq);
  n = deq.size();
  for (int i = 0; i < n; i++) {
    a[i] = deq[i];
    s.insert(a[i]);
  }
  total = ((n * 1LL) * (m * 1LL));
  if (m == 1) {
    trata(deq);
    cout << total << endl;
    return 0;
  }
  deque<int> bordaesq;
  deque<int> bordadir;
  deque<int> v;
  for (int i = 0; i < n; i++) v.push_back(a[i]);
  while (!v.empty()) {
    long long cnt = 0;
    int x = v.front();
    if (v.front() != v.back()) {
      cout << total << endl;
      return 0;
    }
    int le = 0, ri = 0;
    while (!v.empty() and v.front() == x) {
      cnt++;
      v.pop_front();
      le++;
    }
    while (!v.empty() and v.back() == x) {
      cnt++;
      v.pop_back();
      ri++;
    }
    if (!v.empty()) {
      if (cnt % k != 0) {
        total -= cnt * (m - 1);
        total += (cnt % k) * (m - 1);
        cout << total << endl;
        return 0;
      } else {
        total -= cnt * (m - 1);
        for (int i = 0; i < le; i++) bordaesq.push_back(x);
        for (int i = 0; i < ri; i++) bordadir.push_front(x);
      }
    } else {
      cnt *= m;
      if (cnt % k != 0) {
        total -= cnt;
        total += (cnt % k);
        cout << total << endl;
        return 0;
      } else {
        total -= cnt;
      }
    }
  }
  while (!bordadir.empty()) {
    bordaesq.push_back(bordadir.front());
    bordadir.pop_front();
  }
  trata(bordaesq);
  cout << total << endl;
  return 0;
}
