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;
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 - 1) >= k) {
      sum += c[l] * (m - 1) / 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 && b[1] == b[t] && c[1] + c[t] >= k && t != 1) {
    sum = m * n;
  }
  cout << n * m - sum << endl;
}
