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;
pair<int, long long> st[100005];
int arr[100005];
int main() {
  int n, k, m, tp = 0;
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  for (int i = 0; i < n; i++) {
    if (!tp || st[tp - 1].first != arr[i])
      st[tp++] = make_pair(arr[i], 1);
    else
      (++st[tp - 1].second) %= k;
    if (tp && !st[tp - 1].second) tp--;
  }
  long long x = 0, y = 0;
  for (int i = 0; i < tp; i++) x += st[i].second;
  int l = 0, r = tp - 1;
  while (l < r && st[l].first == st[r].first &&
         !((st[l].second + st[r].second) % k))
    y += st[l++].second + st[r--].second;
  long long ans = 0;
  if (l == r) {
    if (!(st[l].second * m % k)) ans -= y;
    ans += x * m - y * (m - 1) - (st[l].second * m / k * k);
  } else {
    if (st[l].first == st[r].first) y += (st[l].second + st[r].second) / k * k;
    ans = x * m - y * (m - 1);
  }
  printf("%lld\n", ans);
  return 0;
}
