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 a[1000050];
pair<long long, long long> q[1000050];
int main() {
  long long n, k, m, low, high, i, j, ans;
  bool same;
  scanf("%lld%lld%lld", &n, &k, &m);
  low = 0;
  high = -1;
  same = true;
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (i > 1 && a[i] != a[i - 1]) same = false;
    if (low <= high && q[high].first == a[i]) {
      q[high + 1] = make_pair((q[high].first), (q[high].second + 1));
      high++;
    } else
      q[++high] = make_pair((a[i]), (1));
    if (low <= high && q[high].second >= k) high -= k;
  }
  if (same) {
    printf("%lld\n", n * m % k);
    return 0;
  }
  ans = (high - low + 1) * m;
  for (; low <= high && q[low].first == q[high].first;) {
    for (i = low; i < high && q[i + 1].first == q[low].first; i++)
      ;
    for (j = high; j > low && q[j - 1].first == q[high].first; j--)
      ;
    if (i >= j) {
      if ((high - low + 1) * m % k == 0)
        ans = 0;
      else
        ans -= (high - low + 1) * m - (high - low + 1) * m % k;
      break;
    }
    if (i - low + 1 + high - j + 1 < k) break;
    ans -= k * (m - 1);
    high -= k - (i - low + 1);
    low = i + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
