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;
const int N = 200020;
long long total;
int k;
deque<int> trata(deque<int> &d) {
  deque<int> at;
  int cnt = 0;
  for (int i = 0; i < d.size(); i++) {
    if (at.empty()) {
      at.push_back(d[i]);
      cnt = 1;
    } else if (at.back() == d[i]) {
      at.push_back(d[i]);
      cnt++;
    } else {
      at.push_back(d[i]);
      cnt = 1;
    }
    if (cnt == k) {
      for (int j = 0; j < k; j++) at.pop_back();
      total -= k;
    }
  }
  return at;
}
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]);
  }
  if (k > 2 * n and s.size() > 1) {
    cout << (n * 1LL) * (m * 1LL) << endl;
    return 0;
  }
  if (k > 2 * n) {
    cout << ((n * 1LL) * (m * 1LL)) % k << endl;
    return 0;
  }
  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;
}
