def decHand(hand)
  case hand
  when GU then PA
  when CHOKI then GU
  when PA then CHOKI
  end
end

GU = 'r'
CHOKI = 's'
PA = 'p'

n, k = gets.split.map(&:to_i)
p_r, p_s, p_p = gets.split.map(&:to_i)
T = gets.chomp.split('')
point = 0
hands = []
T.each_with_index do |t, i|
  x = i - k
  hand = decHand(t)

  if x >= 0
    if hands[x] == hand
      hand = begin
        case hand
        when GU then CHOKI
        when CHOKI then PA
        when PA then GU
        end
      end
    end
  end

  hands << hand
  if (hand == GU) && (t == CHOKI)
    point += p_r
  elsif (hand == CHOKI) && (t == PA)
    point += p_s
  elsif (hand == PA) && (t == GU)
    point += p_p
  end
end
puts point