N,K=gets.chomp.split.map(&:to_i)
R,S,P=gets.chomp.split.map(&:to_i)
T=gets.chomp

score=0
T.each_char.with_index do |c,i|
  if i >= K
    if T[i]==T[i-K]
      T[i]='n'
      next
    end
  end

  score+=P if T[i]=='r'
  score+=S if T[i]=='p'
  score+=R if T[i]=='s'
end
  
puts score