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=map(int,input().split())
a=list(map(int,input().split()))
c=0
k=n*m
for i in range(n*(m-1)):
    a.append(a[i%n])
if (n == 1) or ((k % 2 == 0) and (n<4) and ((a[1]==a[0])or(a[1]==a[2])or(a[0]==a[2]))):
    print(a[0]) 
else:
    while c==0:
        for i in range(k-1):
            if a[i]==a[i+1]:                 
                del(a[i])
                del(a[i+1])
                k = k-2              
                c=0
                break
            else:
                c=1
    print(k)