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 l, r, n, k, m, now, tot, all;
int a[200000], s[200000];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  a[0] = a[n + 1] = -1;
  tot = all = 0;
  for (int i = 1; i <= n + 1; ++i) {
    if (a[i] == a[i - 1])
      tot = (tot + 1) % k;
    else {
      for (int j = i - tot; j <= i - 1; ++j) s[++all] = a[j];
      tot = 1;
    }
  }
  for (int i = 1; i <= all; ++i) a[i] = s[i];
  n = all;
  l = n;
  r = 1;
  now = a[n];
  int totl, totr;
  long long ans = (long long)m * n;
  while (l >= r) {
    totl = totr = 0;
    while (l >= r && now == a[l]) --l, ++totl;
    while (r <= l && now == a[r]) ++r, ++totr;
    if (l + 1 == r) {
      long long sb = 0;
      for (int i = l; i >= 1; --i)
        if (a[i] == now)
          ++sb;
        else
          break;
      for (int i = r; i <= n; ++i)
        if (a[i] == now)
          ++sb;
        else
          break;
      ans = (sb + (long long)(totl + totr) * (m - 1)) % k;
      printf("%I64d\n", ans);
      return 0;
    }
    ans -= ((long long)(totl + totr) / k * k) * (m - 1);
    if ((totl + totr) % k)
      break;
    else
      now = a[l];
  }
  printf("%I64d\n", ans);
  return 0;
}
