N, K = STDIN.gets.chomp.split(' ').map(&:to_i)
R, S, P = STDIN.gets.chomp.split(' ').map(&:to_i)
order = STDIN.gets.chomp.split('')
myhand = []

score = 0
# 5 2
# 8 7 6
# rsrpr
score_map = {:r => :p, :s => :r, :p => :s}

janken = {:r => R, :s => S, :p => P}

order.each_with_index do |x, i|
  result = score_map[x.to_sym]
  if i - K >= 0 && myhand[i - K] == result
    myhand.push(x.to_sym)
  else
    score += janken[result]
    myhand.push(result)
  end
end

puts score

