n, k = gets.strip.split(' ').map(&:to_i)
ro, si, pa = gets.strip.split(' ').map(&:to_i)
t = gets.strip.split('')

# スコアのハッシュ
score = {"r": pa, "s": ro, "p": si }

# tの逆を作る
t_i = []
(-(t.length-1)..0).each do |i|
  t_i[t.length-1 + i] = t[-i]
end

ans = 0
(0..t_i.length-1).each do |i|
  ad = score[t_i[i].to_sym]
  if i >= k && t_i[i]==t_i[i-k]
    ad = 0
    t_i[i] = 'n'
  end
  ans += ad
  puts ad
end
puts ans.to_s

