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;
using ll = long long;
constexpr int N = 100005;
int xs[N], cs[N];
ll work() {
  int n, k, m;
  cin >> n >> k >> m;
  int x, s = 0;
  for (auto _ = (0); _ < (n); _++) {
    cin >> x;
    if (s == 0 || x != xs[s - 1]) {
      xs[s] = x;
      cs[s] = 1;
      s++;
    } else {
      cs[s - 1]++;
      if (cs[s - 1] == k) s--;
    }
  }
  int total = accumulate(cs, cs + s, 0);
  if (m == 1) return total;
  int t = 0;
  while (t < s && xs[t] == xs[s - t - 1] && cs[t] + cs[s - t - 1] == k) t++;
  if (t == s) return (m % 2) * total;
  if (s % 2 && s / 2 == t) return total - cs[t] + ((ll)m * cs[t]) % k;
  return (ll)m * total - (ll)(m - 1) * t * k;
}
int main() {
  cout << work() << endl;
  return 0;
}
