N, K = gets.split.map(&:to_i)
R, S, P = gets.split.map(&:to_i)
T = gets.chomp

history = Hash.new(-1)

ans = 0

T.chars.each_with_index do |t, i|
  next_index = i + K
  before_index = i - K

  case t
  when 'r'
    if history[before_index] == 'p'
      if next_index < N - 1
        history[i] = T[next_index]
      end
    else
      history[i] = 'p'
      ans += P
    end
  when 'p'
    if history[before_index] == 's'
      if next_index < N - 1
        history[i] = T[next_index]
      end
    else
      history[i] = 's'
      ans += S
    end
  when 's'
    if history[before_index] == 'r'
      if next_index < N - 1
        history[i] = T[next_index]
      end
    else
      history[i] = 'r'
      ans += R
    end
  end
end

puts ans
