n=gets.chomp.split("").map(&:to_s)
t=gets.to_i
i=1
count=0
while i<=n.length-1
    #p i
    if n[i-1]==n[i]
        n[i]="#"
        count+=1
        i+=1
        next
   
    end
    i+=1
end
p count*t
