n,k=gets.chomp.split(' ').map(&:to_i)
r,s,p=gets.chomp.split(' ').map(&:to_i)
t=gets.chomp.chars
results = []
n.times do |i|
    if i<k
        if t[i]=="r"
            results<<["p",p]
        elsif t[i]=="s"
            results<<["r",r]
        else
            results<<["s",s]
        end
    else
        if t[i]=="r"&&(results[i-k][0]!="p")
            results<<["p",p]
        elsif t[i]=="s"&&(results[i-k][0]!="r")
            results<<["r",r]
        elsif t[i]=="p"&&(results[i-k][0]!="s")
            results<<["s",s]
        elsif t[i]=="r"
            results<<["r",0]
        elsif t[i]=="s"
            results<<["s",0]
        else
            results<<["p",0]
        end
    end
end

ans = results.inject(0){|sum,num|sum+=num[1]}
puts ans
