n, k = gets.strip.split.map { |v| v.to_i }
r, s, p = gets.strip.split.map { |v| v.to_i }
t = gets.strip.split('').map { |v| v.to_sym }

your_hands = []
hand_to_point = { :r => r, :p => p, :s => s }
points = 0

def hands_with_exception(index, hands)
  return hands[index] if 0 <= index && index < hands.size
  :out_of_bound
end

def hand_to_win(opp_hand, disable_hand, opp_next_hand)
  case opp_hand
  when :r
    return :p if disable_hand != :p
    return :s if opp_next_hand == :s
    return :r
  when :p
    return :s if disable_hand != :s
    return :r if opp_next_hand == :r
    return :p
  when :s
    return :r if disable_hand != :r
    return :p if opp_next_hand == :p
    return :s
  end
end

(0..n-1).each do |i|
  hand = hand_to_win(hands_with_exception(i, t), hands_with_exception(i-k, your_hands), hands_with_exception(i+k, t))
  your_hands.push(hand)
  points += hand_to_point[hand]
  puts hand
end

puts points
