N, K = gets.chomp.split(" ").map{|s| s.to_i}
R, S, P = gets.chomp.split(" ").map{|s| s.to_i}
T = gets.chomp
t_arr = [""] +  T.split("")

f, s, t = "r", "s", "p"
if R >= S && S >= P
  f, s, t = "s", "p", "r"
elsif R >= P && P >= S
  f, s, t = "s", "r", "p"
elsif S >= R && R >= P
  f, s, t = "p", "s", "r"
elsif S >= P && P >= R
  f, s, t = "p", "r", "s"
elsif P >= R && R >= S
  f, s, t = "r", "s", "p"
elsif P >= S && S >= R
  f, s, t = "r", "p", "s"
end

score = {"r"=> P, "p"=> S, "s"=> R}
hand = {f=> {f=> t, s=>t, t=>s}, s=> {f=> t, s=>t, t=>f}, t=> {f=> s, s=>f, t=>s}}

point = 0
T.split("").each_with_index do |c, i|
  bind = [0, i + 1 - K].max
  bhand = t_arr[bind]
  if c != bhand
    point += score[c]
  else
    nind = i+1+K
    t_arr[i+1] = hand[bhand][ t_arr[nind] || f ]
  end
end

puts point

