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())

string = input().replace(' ', '')

# checker = set()

# for c in string:
#     checker.add(c*k)

# if len(checker) == 1:
#   print ((n * m) % k)

# else:
#   checker = list(checker)
  
#   for i in range(len(checker)):
#     if checker[i] in string:
      
#       string.replace(checker[i], '')
#       i = 0
      

ans = m * n

count = 0

sta = [0] * n
stb = [0] * n
            
for i in range(n):
            
    x = string[i]
              
    if count > 0 and sta[count - 1] == x:
              
        stb[count - 1] += 1
                
        if stb[count -1] == k:
                  
            ans -= m * k
            count -= 1
                
    else:
                
        sta[count] = x
        stb[count] = 1
        count += 1
              

l = 0
r = count - 1
            
while r > l and sta[r] == sta[l] :
            
            
    total = stb[l] + stb[r]
                
    if total >= k:
                
        ans -= (m - 1) * (total // k) * k;
                
        if (total % k == 0) :
                  
            l += 1
            r -= 1
                  
        else:
            break


if l == r :
                
    total = stb[l] * m
    
    ans -= (total // k) * k

    if (total % k == 0) :
    
        l -= 1
        r += 1

        while l >= 0 and sta[l] == sta[r]:
        
            total2 = stb[l] + stb[r]
            
            if total2 >= k:
            
                ans -= (total2 // k) * k;

                if total2 % k == 0:
                    l -= 1
                    r += 1
                
                else:
                  break
                        
print(ans)