n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
point = {"r"=>p, "s"=>r, "p"=>s}
flag = {"r"=>true, "s"=>true, "p"=>true}
t = gets.chomp.chars
p t.map.with_index{|ti,i|
  flag[ti] = !flag[ti] if t[i-k]==ti
  (t[i-k]!=ti || flag[ti]) ? point[ti] : 0
}.inject(:+)
