n, k = gets.split.map(&:to_i)
R, S, P = gets.split.map(&:to_i)
table = Hash["s", R, "p", S, "r", P]
win_pattern = Hash["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.append(t[i])
            next
        end
    end
    
    score += table[t[i]]
    hands.append(win_pattern[t[i]])
end

p score