n, k = gets.split(' ').map(&:to_i)
r, s, p = gets.split(' ').map(&:to_i)
t = gets.chomp
points = 0
hands = []
0.upto(t.length - 1) do |i|
  if t[i]=='r'
    if i - k < 0
      points += p
      hands << 'p'
    elsif hands[i-k] != 'p'
      points += p
      hands << 'p'
    else
      hands << 'r'
    end
  elsif t[i]=='s'
    if i - k < 0
      points += r
      hands << 'r'
    elsif hands[i-k] != 'r'
      points += r
      hands << 'r'
    else
      hands << 's'
    end
  else
    if i - k < 0
      points += s
      hands << 's'
    elsif hands[i-k] != 's'
      points += s
      hands << 's'
    else
      hands << 'p'
    end
  end
end
puts points