import Control.Applicative

solve d [] = d
solve [a,b,c,d,e,f] (x:xs)
	| x == 'E' = solve [d,b,a,f,e,c] xs
	| x == 'N' = solve [b,f,c,d,a,e] xs
	| x == 'S' = solve [e,a,c,d,f,b] xs
	| x == 'W' = solve [c,b,f,a,e,d] xs

main = do
	dice <- words <$> getLine
	com <- getLine
	putStrLn $ (!! 0) $ solve dice com