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;
int main() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<long long> repeating(n);
  long long repeatingSize = n;
  long long nonRepeating = 0;
  for (int i = 0; i < n; i++) {
    cin >> repeating[i];
  }
  list<pair<long long, long long>> frequency;
  long long c = -1;
  long long f = 0;
  for (int i = 0; i < n; i++) {
    if (repeating[i] == c) {
      f++;
      if (f == k) {
        repeatingSize -= k;
        if (frequency.empty()) {
          c = -1;
          f = 0;
        } else {
          c = frequency.back().first;
          f = frequency.back().second;
          frequency.pop_back();
        }
      }
    } else {
      if (c >= 0) {
        frequency.push_back(pair<long long, long long>(c, f));
      }
      c = repeating[i];
      f = 1;
    }
  }
  if (c >= 0) {
    frequency.push_back(pair<long long, long long>(c, f));
  }
  if (m > 1) {
    while (frequency.size() > 1 &&
           frequency.front().first == frequency.back().first &&
           frequency.front().second + frequency.back().second >= k) {
      long long x = frequency.front().first;
      long long count = frequency.front().second + frequency.back().second;
      repeatingSize -= k;
      nonRepeating += k;
      frequency.pop_back();
      frequency.pop_front();
      if (count != k) {
        frequency.push_back(pair<long long, long long>(x, count - k));
      }
    }
  }
  if (frequency.size() == 1) {
    if ((frequency.front().second * m) % k == 0) {
      nonRepeating = 0;
    } else {
      nonRepeating += (frequency.front().second * m) % k;
    }
    repeatingSize = 0;
  }
  cout << (nonRepeating + repeatingSize * m) << endl;
}
