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

def calcpoint(sel, r, p, s)
  res = 0
  sel.each_char do |char|
    case char
    when "r" then
      res += r
    when "p" then
      res += p
    when "s" then
      res += s
    end
  end
  res
end

res = t.gsub(/r|p|s/, "r" => "p", "p" => "s", "s" => "r")
#2以下の場合分け
(k..n-1).each do |i|
  #puts i
  if res[i] == res[i-k]
    res[i] = "x"
  end
end
#puts res
puts calcpoint(res, r, p, s)

