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]==n[i+1]
        count+=1
        i+=2
        next
    elsif n[i-1]==n[i]
     count+=1
    i+=1
    next
    end
    i+=1
end
p count*t