class Dice
	def initialize(labels)
		@labels = labels
		@top    = labels[0]
		@front  = labels[1]
		@right  = labels[2]
		@left   = labels[3]
		@back   = labels[4]
		@bottom = labels[5]
	end
	attr_reader :top

	def roll(op)
		case op
		when "E"
			@t      = @top
			@top    = @left
			@left   = @bottom
			@bottom = @right
			@right  = @t
		when "W"
			@t      = @top
			@top    = @right
			@right  = @bottom
			@bottom = @left
			@left   = @t
		when "N"
			@t      = @top
			@top    = @front
			@front  = @bottom
			@bottom = @back
			@back   = @t
		when "S"
			@t      = @top
			@top    = @back
			@back   = @bottom
			@bottom = @front
			@front  = @t
		end
	end
end

labels = gets.strip.split(" ").map{|i| i.to_i}
dice = Dice.new(labels)
ops = gets.strip.split("")

ops.map{|op| dice.roll(op)}

puts dice.top
