n, k = gets.split.map(&:to_i)
rock, scissors, paper = gets.split.map(&:to_i)
t = gets.chomp.chars

res = 0
hands = Array.new(n ,'')

t.each_with_index do |c, current|
  case c
  when 'r'
    if hands[current - k] != 'p'
      hands[current] = 'p'
      res += paper
    end
  when 's'
    if hands[current - k] != 'r'
      hands[current] = 'r'
      res += rock
    end
  when 'p'
    if hands[current - k] != 's'
      hands[current] = 's'
      res += scissors
    end
  end
end

puts res