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 = tuple([int(x) for x in raw_input().rstrip().split()])

a = [int(x) for x in raw_input().rstrip().split()]

stack = [[a[0], 1]]
for aa in a[1:]:
    if aa != stack[-1][0]:
        stack.append([aa, 1])
    else:
        stack[-1][1] += 1
        if stack[-1][1] == k:
            stack.pop()

rem = 0
if m > 1:
    while len(stack) > 1 and stack[0][0] == stack[-1][0]:
        join = stack[0][1] + stack[-1][1]
        if join < k:
            break
        elif join % k == 0:
            stack = stack[1:len(stack) - 1]
            rem += join
        else:
            stack[0][1] -= join % k
            stack[-1][1] = 0
            rem += (join / k) * k

ls = 0
for ss in stack:
    ls += ss[1]

if len(stack) == 0:
    print 0
if len(stack) == 1:
    r = (m * stack[0][1]) % k
    if r == 0:
        print 0
    else:
        print r + rem
else:
    print ls * m + rem