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 = 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;
  }
  if (siz == 1) {
    cout << sum * m % k << 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;
}
