str = gets.split
N,K = str[0].to_i, str[1].to_i
str = gets.split
R,S,P = str[0].to_i, str[1].to_i, str[2].to_i
T = gets.chomp
x = Array.new(N,0)
answer = 0
for i in 0...N do
    if i < K
        if T[i] == "s"
            answer += R
        elsif T[i] == "p"
            answer += S
        else
            answer += P
        end
    else
        if T[i] != T[i-K]
            if T[i] == "s"
                answer += R
            elsif T[i] == "p"
                answer += S
            else
                answer += P
            end
        elsif x[i-K] == 1
            if T[i] == "s"
                answer += R
            elsif T[i] == "p"
                answer += S
            else
                answer += P
            end
        else
            x[i] = 1
        end
    end
end
puts answer