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;
vector<pair<long long, long long> > vc;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k, m;
  cin >> n >> k >> m;
  long long ar[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  stack<pair<long long, long long> > stt;
  for (int i = 0; i < n; i++) {
    if (stt.empty()) {
      stt.push(make_pair(ar[i], 1 % k));
    } else {
      if (stt.top().first == ar[i])
        stt.top().second++, stt.top().second %= k;
      else
        stt.push(make_pair(ar[i], 1 % k));
    }
    if (stt.top().second == 0) stt.pop();
  }
  long long tot = 0;
  while (stt.empty() == false) {
    tot += stt.top().second;
    vc.push_back(stt.top());
    stt.pop();
  }
  int len = vc.size();
  int st = 0, en = len - 1;
  long long cn = 0;
  while (st < en) {
    if (vc[st].first == vc[en].first) {
      if ((vc[st].second + vc[en].second) % k == 0)
        cn += ((vc[st].second + vc[en].second) * (m - 1)), st++, en--;
      else {
        cn += (((vc[st].second + vc[en].second) -
                ((vc[st].second + vc[en].second) % k)) *
               (m - 1));
        break;
      }
    } else
      break;
  }
  if (st == en) {
    if (((vc[st].second) * m) % k == 0) {
      cout << 0 << endl;
      return 0;
    }
    cn += (((vc[st].second) * m) - ((vc[st].second) * m) % k);
  }
  cout << (tot * m - cn) << endl;
  return 0;
}
