#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, k, m;
  bool print = false;
  cin >> n >> k >> m;
  vector<pair<int, int> > cur;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    if (i == 0 && temp == 8) {
      print = true;
    }
    if (cur.empty() || cur.back().first != temp)
      cur.push_back({temp, 1});
    else
      cur.back().second++;
    if (cur.back().second == k) cur.pop_back();
  }
  if (cur.empty()) {
    cout << 0;
    return 0;
  }
  long long total = 0;
  for (auto u : cur) total += u.second;
  if (m == 1) {
    cout << total;
    return 0;
  }
  int sptr = 0, eptr = cur.size() - 1;
  total = m * (total);
  while (sptr < eptr) {
    if (cur[sptr].first != cur[eptr].first) {
      cout << total;
      return 0;
    }
    long long join = cur[sptr].second + cur[eptr].second;
    if (join < k) {
      cout << total;
      return 0;
    } else if (join > k) {
      total -= (m - 1) * k;
      cout << total;
      return 0;
    } else {
      total -= (m - 1) * k;
      sptr++;
      eptr--;
    }
  }
  if (sptr == eptr) {
    long long val = (long long)cur[sptr].second * m;
    if (val % k == 0) {
      cout << 0;
      return 0;
    }
    total = (total - (val / k) * k);
  }
  cout << total;
  return 0;
}
