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 n, k, m, x;
long long f[100005][2];
long long top, l, r;
long long sum;
int main() {
  scanf("%I64d%I64d%I64d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", &x);
    if (top == 0) {
      ++top;
      f[top][0] = x;
      f[top][1] = 1;
    } else {
      if (f[top][0] == x)
        f[top][1]++;
      else {
        ++top;
        f[top][0] = x;
        f[top][1] = 1;
      }
    }
    if (f[top][1] == k) {
      f[top][1] = 0;
      --top;
    }
  }
  sum = 0;
  for (int i = 1; i <= top; ++i) sum += f[i][1];
  if (top == 0) {
    cout << 0 << endl;
    return 0;
  }
  l = 1;
  r = top;
  while (l < r) {
    if (f[l][0] != f[r][0]) break;
    if ((f[l][1] + f[r][1]) % k == 0) {
      r--;
      l++;
    } else {
      f[l][1] = (f[l][1] + f[r][1]) % k;
      f[r][1] = 0;
      break;
    }
  }
  long long ans = 0;
  if (r == l) {
    if (f[l][1] * m % k == 0)
      ans = 0;
    else {
      ans = sum + f[l][1] * (m - 1);
      ans -= (f[l][1] * m) - (f[l][1] * m % k);
    }
  } else {
    for (int i = l; i <= r; ++i) ans += f[i][1];
    ans *= (m - 1);
    ans += sum;
  }
  cout << ans << endl;
  return 0;
}
