#include <bits/stdc++.h>
using namespace std;
int n, k, m;
int a[100000 + 10], f[100000 + 10];
int main() {
  cin >> n >> k >> m;
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  vector<pair<int, int> > g;
  for (int i = 0; i < n; i++) {
    if (g.size() == 0 || g.back().first != a[i])
      g.push_back(make_pair(a[i], 1));
    else
      g.back().second++;
    if (g.back().second == k) g.pop_back();
  }
  long long ans = 0;
  for (int i = 0; i != g.size(); i++) ans += g[i].second;
  if (g.size() == 0 || m == 1) {
    cout << ans << endl;
    return 0;
  }
  ans *= m;
  int i = 0, j = g.size();
  j--;
  while (i < j) {
    if (g[i].first == g[j].first && g[i].second + g[j].second == k) {
      i++;
      j--;
      ans -= (long long)(m - 1) * k;
      continue;
    }
    long long extra = 0;
    if (g[i].first == g[j].first && g[i].second + g[j].second >= k)
      extra += (long long)k * (m - 1);
    ans -= extra;
    cout << ans << endl;
    return 0;
  }
  if (i > j)
    cout << 0 << endl;
  else {
    if (((long long)m) * g[i].second % k == 0)
      ans = 0;
    else
      ans -= (((long long)m) * g[i].second / k) * k;
    cout << ans << endl;
  }
  return 0;
}
