n, k = gets.split.map(&:to_i)
R, S, P = gets.split.map(&:to_i)
t = gets.chomp.split("")
score = 0
hands = []

def win_pattern(t)
    case t
    when "s"
        "r"
    when "p"
        "s"
    when "r"
        "p"
    end
end

def table(t)
    case t
    when "s"
        R
    when "p"
        S
    when "r"
        P
    end
end

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

puts score