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

groups = t.group_by.with_index { |s, i| i % k }.values.map(&:join)
max = groups.map do |group|
  m = 0
  len = group.length
  pattern = 'rsp'.chars.repeated_permutation(len).to_a.map(&:join)
  pattern.reject! do |pat|
    pat.include?('rr') || pat.include?('ss') || pat.include?('pp')
  end
  
  pattern.each do |pat|
    sum = 0
    (0..len-1).each do |l|
      if pat[l] == 'r' && group[l] == 's'
        sum += r
      elsif pat[l] == 's' && group[l] == 'p'
        sum += s
      elsif pat[l] == 'p' && group[l] == 'r'
        sum += p
      end
    end
    m = [m, sum].max
  end
  
  m
end

puts max.inject(:+)
