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;
const int Max = 1e5 + 100;
struct node {
  long long data[Max];
  long long top = -1;
} sta;
int main() {
  long long n, k, m, i, num = 0, pre = 0;
  scanf("%lld%lld%lld", &n, &k, &m);
  for (int a = 0; a < n; a++) {
    scanf("%lld", &i);
    sta.data[++sta.top] = i;
    if (sta.top >= k - 1) {
      int now = 0;
      for (int b = sta.top; b >= 0; b--) {
        if (sta.data[b] != i) break;
        now++;
        if (now == k) {
          sta.top -= k;
        }
      }
    }
  }
  pre = sta.data[0], i = 0, num = 0;
  long long sum = 0, ans, flag = 0, one = 0, two = 0;
  long long j, sss = 0;
  bool ste = 0;
  for (j = sta.top; i <= j;) {
    if (sta.data[i] == pre) {
      num++;
      i++;
      if (!flag) one++;
    }
    if (sta.data[j] == pre) {
      num++;
      j--;
      if (!flag) two++;
    }
    if (i > j) break;
    if (sta.data[i] != pre && sta.data[j] != pre) {
      if (num % k != 0) {
        ste = 1;
        sss = num - num % k;
        break;
      }
      sum += num;
      num = 0;
      pre = sta.data[i];
      flag = 1;
    }
  }
  if (one + two >= sta.top + 1) {
    printf("%lld\n", n * m % k);
    return 0;
  }
  if (ste == 0) {
    if ((num - 1) * m % k == 0) {
      ans = 0;
    } else {
      ans = (num - 1) * m % k + sum;
    }
  } else {
    ans = (sta.top + 1 - sum) * m - sss * (m - 1);
    ans += sum;
  }
  printf("%lld\n", ans);
  return 0;
}
