f = gets.split
commands = gets.rstrip.each_char

commands.each do |c|
	case c
	when ?E
		f[0], f[2], f[5], f[3] = f[3], f[0], f[2], f[5]
	when ?N
		f[0], f[1], f[5], f[4] = f[1], f[5], f[4], f[0]
	when ?S
		f[0], f[1], f[5], f[4] = f[4], f[0], f[1], f[5]
	when ?W
		f[0], f[2], f[5], f[3] = f[2], f[5], f[3], f[0]
	end
end

puts f[0]