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 solve() {
  long long n, m, k, i, x;
  cin >> n >> k >> m;
  vector<pair<long long, long long> > v;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (!v.empty() and v.back().first == x) {
      v.back().second++;
      if (v.back().second == k) v.pop_back();
    } else
      v.push_back({x, 1});
  }
  long long ans = 0;
  for (auto it : v) ans += it.second;
  if (m == 1 or ans == 0) return cout << ans, 0;
  ans *= m;
  long long st = 0, ed = v.size() - 1;
  while (st < ed) {
    if (v[st].first != v[ed].first) return cout << ans, 0;
    if (v[st].second + v[ed].second == k) {
      ans -= (m - 1) * k;
      st++, ed--;
    } else {
      if (v[st].second + v[ed].second > k) ans -= (m - 1) * k;
      cout << ans;
      return 0;
    }
  }
  if (st == ed) {
    long long rmv = v[st].second * m;
    cout << ans - (rmv / k) * k;
  } else if (st > ed) {
    cout << 0;
    return 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
