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 }

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