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

arr = []
result = 0

0.upto(t.length-1) do |i|
  c = t[i]

  if c == "r" && (i < k || arr[i-k] != "p")
    result += p
    arr << "p"
  elsif c == "s" && (i < k || arr[i-k] != "r")
    result += r
    arr << "r"
  elsif c == "p" && (i < k || arr[i-k] != "s")
    result += s
    arr << "s"
  else
    arr << c
  end
end

puts result
