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

hand_to_score_hash = { 'r' => R, 's' => S, 'p' => P }
win_hand_map = { 'r' => 'p', 's' => 'r', 'p' => 's' }
total_score = 0
N.times do |i|
  win_hand = win_hand_map[T[i]]
  add_score = hand_to_score_hash[win_hand]
  if i >= K && T[i] == T[i - K]
    add_score = 0
    T[i] = 'n'
  end
  total_score += add_score
end
puts total_score
