class Dice
	attr_reader :top

  def initialize(ary)
    @top, @front, @right, @left, @back, @bottom = ary
  end

  def roll(way)
    case way.downcase
    when 'e'
      tmp = @top
      @top = @left
			@left = @bottom
			@bottom = @right
			@right = tmp
    when 'w'
			tmp = @top
			@top = @right
			@right = @bottom
			@bottom = @left
			@left = tmp
    when 's'
			tmp = @top
			@top = @back
			@back = @bottom
			@bottom = @front
			@front = tmp
    when 'n'
			tmp = @top
			@top = @front
			@front = @bottom
			@bottom = @back
			@back = tmp
    end
  end
end

dice = Dice.new(gets.chomp.split(/\s/).map(&:to_i))
order = gets.chomp.split('')
order.each{ |way| dice.roll(way) }
puts dice.top