class Dice < Array
	def roll(drct)
		self.replace(drct.split("").inject([]){|arr, s|
		case s
		when "E" then
			arr = [at(3),at(1),at(0),at(5),at(4),at(2)]
		when "N" then
			arr = [at(1),at(5),at(2),at(3),at(0),at(4)]
		when "S" then
			arr = [at(4),at(0),at(2),at(3),at(5),at(1)]
		when "W" then
			arr = [at(2),at(1),at(5),at(0),at(4),at(3)]
		end
		})
	end
	def top
		at(0)
	end
end

a = Dice.new(gets.split.map(&:to_i))
a = a.roll(gets.chomp)
puts a.top