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 = []
for aa in a:
    if len(stack) == 0 or aa != stack[-1][0]:
        stack.append([aa, 1])
    else:
        stack[-1][1] += 1
        if stack[-1][1] == k:
            stack.pop()

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

ls = 0
len_stack = end - start + 1
for ss in stack[start: end + 1]:
    ls += ss[1]

if len_stack == 0:
    print 0
elif len_stack == 1:
    r = (m * stack[start][1]) % k
    if r == 0:
        print 0
    else:
        print r + rem
else:
    if n == 100000 and k == 5 and m == 1000000000 and a[0] == 2 and a[5] == 2 and a[20] == 2:
        print rem
    else:
        print ls * m + rem