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

n,k,m = input().strip().split()
n = int(n)
k = int(k)
m = int(m)
a = list(map(int, input().strip().split()))
x = []
kol = 1
for i in range(n):
  if i ==0:
    x.append((a[i],kol))
  else:
    if a[i] == a[i-1]:
      kol +=1
      x.append((a[i],kol))
    else:
      kol = 1
      x.append((a[i],kol))
i = n-1
s = n
l=0
if k>=n:
  for i in range(n):
    if n ==1 or (i>0 and a[i]!=a[i-1]):
      if k <= n*m:
        print((n *m) % k)
      else:
        print(n*m)
      l =1
      break
  if l==0:
    print(0)
else:
  while i  >= n//2 :
    if x[i] == x[n -1 - i  + x[i][1] - 1] and x[i][1] * 2 >=k:
      if i !=n -1 - i  + x[i][1] - 1:
        s -= x[i][1] *2
      else:
        s-= x[i][1]
      i = i - x[i][1]
    else:
      s = s * ((m//2)*2)
      i =-1
  if m %2 != 0:
    s =s +n
  print(max(s,0))
  