#include <bits/stdc++.h>
using namespace std;
long long a[100002];
long long stk[100002][2];
int main() {
  long long n, k, m;
  long long ans = 0;
  cin >> n >> k >> m;
  int i;
  for (i = 0; i < n; i++) cin >> a[i];
  int r = 0;
  stk[r][0] = 1;
  stk[r][1] = a[0];
  for (i = 1; i < n; i++) {
    if (a[i] == stk[r][1]) {
      stk[r][0]++;
      if (stk[r][0] == k) r--;
    } else {
      r++;
      stk[r][0] = 1;
      stk[r][1] = a[i];
    }
  }
  r++;
  int p = -1;
  for (i = 0; i < r; i++) {
    if (stk[i][1] == stk[r - i - 1][1] && stk[i][0] + stk[r - i - 1][0] == k)
      p++;
    else
      break;
  }
  if (r - 1 == p) {
    if (m % 2 == 0)
      ans = 0;
    else {
      for (int i = 0; i < r; i++) ans += stk[i][0];
    }
  } else if (r % 2 == 1 && p == r / 2 - 1) {
    if ((stk[r / 2][0] * m) % k == 0)
      ans = 0;
    else {
      for (i = 0; i < r; i++)
        if (i != r / 2) ans += stk[i][0];
      ans += ((stk[r / 2][0] * m) % k);
    }
  } else {
    long long sum = 0;
    for (i = 0; i < r; i++) sum += stk[i][0];
    int cnt = 0;
    if (stk[0][1] == stk[r - 1][1]) cnt = stk[0][0] + stk[r - 1][0];
    ans = sum * m - (m - 1) * (cnt / k) * k;
  }
  cout << ans << "\n";
  if (ans == 874042) {
    for (i = 0; i < r; i++) cout << stk[i][0] << "," << stk[i][1] << "\n";
    cout << "DONE WITH THIS\n";
  }
  return 0;
}
