n, k = gets.chop.split.map(&:to_I)
r, s, p = gets.chop.split.map(&:to_I)
t = gets.chop.cahrs

hands = { 's': r, 'p': s, 'r': p }
groups = t.group_by.with_index { |s, i| i % k }.values
max = groups.map do |group|
  m = 0
  len = group.length
  len.times do |l|
  	prev = nil
    val = group.rotate(l).map do |t|
      if t == prev
        0
      else
        hands[t]
      end
    end.inject(:+)
    m = [m, val].max
  end
  m
end

puts max.inject(:+)
