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

r=lambda:map(int,input().split())
n,k,m=r()
a=list(r())
stck=[]
stck
if k==1:
	print(0)
	exit(0)
if n==1 and m >=k:
	print(m%k)
	exit(0)
for i in range(n):#this is team formation possible in a bus itself
	if len(stck)==0:
		stck.append((a[i],1))
		prevV=a[i]
		prevL=1			
	elif a[i]==prevV:
		prevL+=1
		stck.append((a[i],prevL))
	else:
		stck.append((a[i],1))
		prevV=a[i]
		prevL=1
	if prevL==k:
		stck=stck[:len(stck)-k]
p=0
r=len(stck)

for i in range(r//2):
	if stck[i][0]==stck[r-i-1][0] and stck[i][1]+stck[r-i-1][1]==k:
		p+=1
if p==(r//2) and m%2==0:
	print(0)
elif p==(r//2) and m%2 !=0:
	print(r)
elif p!=(r//2):
	print(m*r-(m-1)*(p+1))
