n, k = gets.split.map(&:to_i)
R, S, P = gets.split.map(&:to_i)
table = {"s" => R, "p" => S, "r" => P}
win_pattern = {"s" => "r", "p" => "s", "r" => "p"}
t = gets.chomp.split("")
score = 0
hands = []
 
n.times do |i|
    if i > k - 1
        if win_pattern[t[i]] == hands[i - k]
            hands.push(t[i])
            next
        end
    end
    
    score += table[t[i]]
    hands.push(win_pattern[t[i]])
end
 
p score