import Control.Applicative
import Control.Monad

-- TSEWNB
roll [] d = d
roll (o:os) d 
  | o == 'N' = roll os $ [d!!1,d!!5,d!!2,d!!3,d!!0,d!!4]   -- 0->4->5->1->0
  | o == 'E' = roll os $ [d!!3,d!!1,d!!0,d!!5,d!!4,d!!2]   -- 0->2->5->3->0
  | o == 'W' = roll os $ [d!!2,d!!1,d!!5,d!!0,d!!4,d!!3]   -- 0->3->5->2->0
  | o == 'S' = roll os $ [d!!4,d!!0,d!!2,d!!3,d!!5,d!!1]   -- 0->1->5->4->0

main = do
  label <- words <$> getLine
  order <- getLine
  let d = roll order [0..5]
  putStrLn $ label!!(d!!0)