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, m, k;
int a[100005];
int len[100005];
void print(long long s, long long t) {
  cout << (t - s + 1) * m + (s - 1) + (n - t);
}
int main() {
  cin >> n >> k >> m;
  int numm = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] != a[i - 1])
      numm = 1;
    else
      numm++;
    len[i] = numm;
    if (numm == k) {
      i -= k;
      n -= k;
      numm = len[i];
    }
  }
  if (k >= n) {
    bool g = 1;
    for (int i = 2; i <= n; i++)
      if (a[i] != a[i - 1]) {
        g = 0;
        break;
      }
    if (g == 1)
      cout << n * m % k;
    else
      cout << n * m;
    return 0;
  }
  if (m == 1) {
    cout << n;
    return 0;
  }
  long long i = 1, j = n;
  while (i <= j) {
    if (a[i] != a[j]) {
      print(i, j);
      return 0;
    }
    int jj = j, ii = i;
    while (i < j && a[j] == a[j - 1]) j--;
    if (i == j) {
      j = jj;
      if (((j - i + 1) * m) % k == 0)
        cout << '0';
      else
        cout << ((j - i + 1) * m) % k + (i - 1) + (n - j);
      return 0;
    }
    while (a[i] == a[j] && (i - ii + 1) + (jj - j + 1) < k) i++;
    if (a[i] == a[j]) {
      i++;
      j--;
    } else {
      i = ii;
      j = jj;
      print(i, j);
      return 0;
    }
  }
}
