io = STDIN
n,k=io.gets.split.map(&:to_i)
R,S,P=io.gets.split.map(&:to_i)
t=io.gets.chomp.split(//)
score={
  "r"=>R,
  "s"=>S,
  "p"=>P,
  "e"=>0
}
w={
  "r"=>"p",
  "s"=>"r",
  "p"=>"s",
}
win=t.map{|ch|w[ch]}
(k...n).each do |i|
  win[i]='e' if win[i-k]==win[i]
end
puts win.map{|ch|score[ch]}.inject(:+)
