N, K = gets.chomp.split(" ").map(&:to_i)
R, S, P = gets.chomp.split(" ").map(&:to_i)
Ary1 = gets.chomp.split("")
Ary2 = []

Ary1.each do |i|
    if i == "r"
        Ary2 << "p"
    elsif i == "p"
        Ary2 << "s"
    else
        Ary2 << "r"
    end
end

for i in (0..(Ary1.length - K))
    if Ary2[i] == Ary2[i + K]
        Ary2[i + K] = 0
    end
end

sum = R * Ary2.count("r") + S * Ary2.count("s") + P * Ary2.count("p") 

puts sum
