n,k = gets.split.map(&:to_i)
r,s,p = gets.split.map(&:to_i)
str = gets.chomp
j = Array.new(n)
point = 0


str.length.times do |i|
    flag = true
    if i>=k
        if str[i] == str[i-k] and j[i-k] == true
            flag = false
        end
    end
    j[i] = flag
    if flag
        point += p if str[i] == 'r'
        point += r if str[i] == 's'
        point += s if str[i] == 'p'
    end
end

p point