#include <bits/stdc++.h>
using namespace std;
long long n, k, m;
long long a[100005], num, p, sum;
struct node {
  long long v, h;
} nd[100005];
int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (a[i] != nd[num].v) {
      nd[++num].v = a[i];
      nd[num].h = 1;
    } else if (++nd[num].h == k)
      num--;
  }
  for (int i = 1; i <= num; i++) sum += nd[i].h;
  if (k >= sum) {
    if (num != 1)
      cout << sum * m << endl;
    else
      cout << (sum * m) % k << endl;
    return 0;
  }
  long long les = 0, flag = 0;
  for (int i = 1; i <= num; i++) {
    if (nd[i].v != nd[num - i + 1].v) break;
    if ((nd[i].h + nd[num - i + 1].h) % k) {
      if (num % 2 && i == (num + 1) / 2) flag = 1;
      les += nd[i].h + nd[num - i + 1].h - (nd[i].h + nd[num - i + 1].h) % k;
      break;
    }
    les += nd[i].h + nd[num - i + 1].h;
  }
  if (les == 2 * sum) {
    cout << (m % 2) * sum << endl;
  } else if (flag) {
    if (nd[(num + 1) / 2].h * m % k == 0)
      printf("0\n");
    else
      cout << nd[(num + 1) / 2].h * m % k + sum - nd[(num + 1) / 2].h << endl;
  } else
    cout << sum * m - (m - 1) * les << endl;
  return 0;
}
