#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, k, m, a[N];
long long core, sum, tot, siz;
vector<pair<int, int> > b, rb;
void deal() {
  for (int i = 1; i <= n; i++)
    if (b.size() && b.back().first == a[i])
      b.back().second++;
    else {
      if (b.size()) {
        b.back().second %= k;
        if (!b.back().second) b.pop_back();
        if (!b.size() || b.back().first != a[i])
          b.push_back(make_pair(a[i], 1));
        else
          b.back().second++;
        b.back().second %= k;
        if (!b.back().second) b.pop_back();
      } else
        b.push_back(make_pair(a[i], 1));
    }
  if (b.size()) {
    b.back().second %= k;
    if (!b.back().second) b.pop_back();
  }
  for (pair<int, int> v : b) sum += v.second;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  deal();
  siz = b.size();
  if (!siz) {
    cout << 0 << endl;
    return 0;
  }
  if (m == 1) {
    cout << sum << endl;
    return 0;
  }
  for (int i = siz - 1; i >= 0; i--) rb.push_back(b[i]);
  for (int i = 0; i < siz; i++) {
    if (b[i].first != rb[i].first) break;
    tot += b[i].second + rb[i].second - (b[i].second + rb[i].second) % k;
    if ((b[i].second + rb[i].second) % k) {
      if (siz & 1 && i == siz / 2) core = b[i].second;
      break;
    }
  }
  if (tot != sum * 2) {
    if (core) {
      if (core * m % k == 0)
        cout << 0 << endl;
      else
        cout << core * m % k + sum - b[siz / 2].second << endl;
    } else
      cout << sum * m - tot * (m - 1) << endl;
  } else if (m % 2)
    cout << sum << endl;
  else
    cout << 0 << endl;
}
