n,k=gets.chomp.split.map(&:to_i)
r,s,p=gets.chomp.split.map(&:to_i)
t=gets.chomp.split("")
tt=[]
win={'r' => 'p', 'p' => 's', 's' => 'r'}
sc={'r' => r, 'p' => p, 's' => s}
ans=0
t.each_with_index do |v,i|
  if i < k
    ans += sc[win[v]]
    tt << win[v]
  else
    if win[v] == tt[i-k]
      tt << 'q'
    else
      ans += sc[win[v]]
      tt << win[v]
    end
  end
end
puts ans