n,k=gets.chomp.split(' ').map(&:to_i)
r,s,p=gets.chomp.split(' ').map(&:to_i)
t = gets.to_s

ta = t.chars
arr = []
flg = true
ta.each_with_index do |str, i|
  break if str == "\n"
  if i >= k && flg == true
    if ta[i-k] == str
      arr << 'x' + str
      flg = false
      next
    end
  end

  arr << str
  flg = true
end

ans = 0
arr.each_with_index do |str, i|
  case str
  when 's'
    ans += r
  when 'p'
    ans += s
  when 'r'
    ans += p
  end
end

puts ans
