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;
const int N = 200005;
int a[N], cnt[N];
int n, m, k;
int main() {
  scanf("%d %d %d", &n, &k, &m);
  map<int, int> num;
  for (int i = 0; i < n; i++) scanf("%d", a + i), num[a[i]]++;
  if (num.size() == 1) {
    int res = (ll)n * m % k;
    printf("%d\n", res);
    return 0;
  }
  vector<int> v[2];
  for (int i = 0; i < n; i++) {
    v[0].push_back(a[i]);
    if (i && a[i] == a[i - 1])
      cnt[i] = cnt[i - 1] + 1;
    else
      cnt[i] = 1;
    if (cnt[i] >= k) v[0].resize(v[0].size() - cnt[i]), cnt[i] -= k;
  }
  ll res = v[0].size();
  if (m == 1) {
    printf("%lld\n", res);
    return 0;
  }
  v[1] = v[0];
  for (int i = 0; i < v[1].size(); i++) {
    v[0].push_back(v[1][i]);
    int id = v[0].size() - 1;
    if (v[0].end()[-1] == v[0].end()[-2])
      cnt[id] = cnt[id - 1] + 1;
    else
      cnt[id] = 1;
    if (cnt[id] >= k) v[0].resize(v[0].size() - cnt[id]);
  }
  if (v[0].empty()) {
    if (~m & 1) res = 0;
    printf("%lld\n", res);
    return 0;
  }
  ll dec = res * 2 - v[0].size();
  ll ans = res * m - (m - 1) * dec;
  printf("%lld\n", ans);
  return 0;
}
