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 s1[100005];
long long node[100005][2];
int main() {
  long long n, k, m;
  while (scanf("%lld%lld%lld", &n, &k, &m) != EOF) {
    long long all = 0;
    for (long long a = 1; a <= n; a++) {
      int temp;
      scanf("%d", &temp);
      if (!all || temp != node[all][0]) {
        all++;
        node[all][0] = temp;
        node[all][1] = 1;
      } else
        node[all][1]++;
      if (node[all][1] == k) node[all--][1] -= k;
    }
    long long sum = 0;
    for (long long a = 1; a <= all; a++) sum += node[a][1];
    long long l = 1, r = all;
    while (l < r && node[l][0] == node[r][0]) {
      long long temp = (node[l][1] + node[r][1]) % k;
      if (temp == 0) {
        l++;
        r--;
      } else {
        node[l][1] = temp;
        node[r][1] = 0;
        break;
      }
    }
    long long ans = 0;
    if (l < r) {
      long long temp = 0;
      for (long long a = l; a <= r; a++) temp += node[a][1];
      ans = (m - 1) * temp + sum;
    } else if (l == r) {
      if ((node[l][1] * m) % k == 0)
        ans = 0;
      else {
        ans = sum + node[l][1] * (m - 1);
        ans -= node[l][1] * m - node[l][1] * m % k;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
