class Dice
	def initialize()
		# top bottom N E S W
		@dice_number = [1, 6, 5, 3, 2, 4]
	end

	def throw(command)
		swap_number = []

		case command
		when 'N'
			swap_number = [2, 1, 4]
			swap(swap_number)
		when 'E'
			swap_number = [3, 1, 5]
			swap(swap_number)
		when 'S'
			swap_number = [4, 1, 2]
			swap(swap_number)
		when 'W'
			swap_number = [3, 1, 5]
			swap(swap_number)
		end
	end

	def swap(number)
		number.map do |n|
			@dice_number[0], @dice_number[n] = @dice_number[n], @dice_number[0]
		end
	end

	def top
		@dice_number[0]
	end
end

number = gets.split.map(&:to_i)
command = gets.chomp.split("")

dice = Dice.new

command.map do |c|
	dice.throw(c)
end

puts number[dice.top-1]