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 }

hand_to_point = { :r => r, :p => p, :s => s }

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

def which_hand_and_win?(opp_hand, disable_hand, opp_next_hand)
  case opp_hand
  when :r
    return [:p, true] if disable_hand != :p
    return [:s, false] if opp_next_hand == :s
    return [:r, false]
  when :p
    return [:s, true] if disable_hand != :s
    return [:r, false] if opp_next_hand == :r
    return [:p, false]
  when :s
    return [:r, true if disable_hand != :r
    return [:p, false] if opp_next_hand == :p
    return [:s, false]
  end
end

your_hands = []
points = 0
(0..n-1).each do |i|
  hand, win = which_hand_and_win?(hand(t, i), hand(your_hands, i - k), hand(t, i + k))
  your_hands.push(hand)
  points += hand_to_point[] if win
end

puts points
