require 'pp'

n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
ch = gets.chomp!.chars

sum = 0
memo = Array.new(n)
ch.each_with_index do |c, i|
    if c == 'r' # グー
        next if memo[i - k] && memo[i - k] == 'p'

        memo[i] = 'p'
        sum += p
    elsif c == 's' # チョキ
        next if memo[i - k] && memo[i - k] == 'r' 

        memo[i] = 'r'
        sum += r
    else # パー 
        next if memo[i - k] && memo[i - k] == 's'

        memo[i] = 's'
        sum += s
    end
end

puts sum
