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;
const long long N = 1e5 + 6;
long long f[N], s[N];
signed main() {
  long long n, k, m;
  cin >> n >> k >> m;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  if (k >= n) {
    bool allSame = true;
    for (long long i = 1; i < n; ++i) allSame &= (a[i] == a[i - 1]);
    if (allSame)
      cout << n * m % k;
    else
      cout << n * m;
    return 0;
  }
  long long top = 0;
  for (long long i = 0; i < n; ++i) {
    s[++top] = a[i];
    if (top > 1 && s[top] == s[top - 1]) {
      f[top] = f[top - 1] + 1;
    } else {
      f[top] = 1;
    }
    if (f[top] == k) top -= k;
  }
  long long L = 1, R = top;
  long long ans = 0;
  while (s[L] == s[R] && L != R) {
    long long cnt = 0, l = L, r = R;
    while (s[l] == s[L] && l < r && cnt < k) ++l, ++cnt;
    while (s[r] == s[R] && l < r && cnt < k) --r, ++cnt;
    if (cnt == k) {
      L = l, R = r, ans += k;
    } else {
      break;
    }
  }
  bool allSame = true;
  for (long long i = L + 1; i <= R; ++i) {
    allSame &= (s[i] == s[i - 1]);
  }
  if (allSame) {
    if ((R - L + 1) * m % k == 0) {
      cout << 0 << '\n';
    } else {
      cout << (R - L + 1) * m % k + ans;
    }
  } else {
    cout << (R - L + 1) * m + ans;
  }
}
