#include <bits/stdc++.h>
using namespace std;
int a[100000 + 20], b[100000 + 20], c[100000 + 20];
long long n, k, m, t = 0, l, r, i, j;
long long sum = 0;
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= n; i++) {
    if (a[i] != b[t]) {
      b[++t] = a[i];
      c[t] = 1;
    } else {
      c[t]++;
      if (c[t] == k) {
        sum += m * k;
        t--;
      }
    }
  }
  l = 1;
  r = t;
  while (l <= r) {
    if (b[l] != b[r]) break;
    if (l == r && c[l] * m >= k) {
      sum += c[l] * m / k * k;
      break;
    }
    if (c[l] + c[r] >= k) {
      sum += k * (m - 1);
      if (c[l] + c[r] > k)
        break;
      else
        l++, r--;
    } else
      break;
  }
  if (l == r && c[l] * m % k == 0) {
    sum = 1ll * n * m;
  }
  cout << n * m - sum << endl;
}
