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;
long long n, m, k;
long long ans;
vector<long long> s;
bool solve(vector<long long>& s, long long lb, long long rb) {
  if (lb > rb) return false;
  if (s[lb] != s[rb]) return false;
  long long l, r;
  for (l = lb; l + 1 <= rb && s[l + 1] == s[l]; l++)
    ;
  for (r = rb; r - 1 >= rb && s[r - 1] == s[r]; r--)
    ;
  if (l == rb) {
    long long tot = m * (rb - lb + 1);
    ans += tot / k * k;
    return tot % k == 0;
  } else {
    long long len = (l - lb + 1) + (rb - r + 1);
    if (len % k == 0) {
      ans += len * (m - 1);
      if (solve(s, l + 1, r - 1)) {
        ans += len;
        return true;
      }
      return false;
    } else {
      ans += (m - 1) * ((len / k) * k);
      return false;
    }
  }
}
vector<long long> prep(vector<long long>& s) {
  int run = 0;
  int pre = '*';
  vector<long long> r;
  for (int c : s) {
    if (run == 0 || c != pre) {
      for (int i = 0; i < run % k; i++) r.push_back(pre);
      run = 1, pre = c;
    } else {
      run++;
    }
  }
  for (int i = 0; i < run % k; i++) r.push_back(pre);
  return r;
}
long long solve() {
  vector<long long> ns = prep(s);
  if (ns.empty())
    return 0;
  else {
    solve(ns, 0, ns.size() - 1);
    return ns.size() * m - ans;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> m;
  s.resize(n);
  for (long long i = 0; i < (n); ++i) cin >> s[i];
  cout << solve() << endl;
}
