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

from sys import stdin
rr = lambda: stdin.readline().strip()
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
def rry(N = None, f = rri):
    for i in xrange(N or rri()):
        yield f()

from itertools import groupby
debug=0
if debug:
    fi = open('t.txt','r')
    rr = lambda: fi.readline().replace('\n','')


#N, K, M = rrm()
#A = rrm()
"""
def brute(N, K, M, A):
    B =[]
    for _ in xrange(M):
        B.extend(A)
    def metacompress(B):
        nice = safety = True
        while nice or safety:
            if not nice: safety = False
            else: safety = True
            B, nice = compress(B)
        return B

    def compress(B):
        ans = []
        nice = False
        for k, v in groupby(B):
            w = list(v)
            a = 0
            while a*K + K <= len(w):
                a += 1
            if a:
                nice = True
                w = w[K*a:]
            ans.extend(w)
        return ans, nice
    B = metacompress(B)
    return len(B)
"""
def solve(N, K, M, A):
    def metacompress(B):
        nice = safety = True
        while nice or safety:
            if not nice: safety = False
            else: safety = True
            B, nice = compress(B)
        return B

    def compress(B):
        ans = []
        nice = False
        for k, v in groupby(B):
            w = list(v)
            a = 0
            while a*K + K <= len(w):
                a += 1
            if a:
                nice = True
                w = w[K*a:]
            ans.extend(w)
        return ans, nice

    a = 1
    powers = [metacompress(A)]
    while True:
        a *= 2
        if a <= M:
            c = metacompress(powers[-1] + powers[-1])
            powers.append(c)
            if len(c) > 300*N: break
            #if not nice: break
        else:
            break

    ans = 0
    make = []
    for i,x in enumerate(bin(M)[2:][::-1]):
        if x =='1':
            if i < len(powers):
                make.extend(powers[i])
            else:
                j = len(powers) - 1
                ans += len(powers[-1]) * (2 ** (i-j))

    return ans + len(metacompress(make))

N,K,M = rrm()
print solve(N,K,M,rrm())

"""
from random import randint as rint
for _ in xrange(1000):
    print '.',
    N = 10
    K = rint(2, 5)
    M = 10
    A = [rint(1,2) for _ in xrange(N)]
    if not( solve(N,K,M,A) == brute(N,K,M,A) ):
        print 'oops', N, K, M, A
"""
