import Control.Applicative

rDice insts = let
    rDiceStep [r1,r2,r3,r4,r5,r6] (i:is) = case i of
      'W' -> rDiceStep [r3,r2,r6,r1,r5,r4] is
      'E' -> rDiceStep [r4,r2,r1,r6,r5,r3] is
      'N' -> rDiceStep [r2,r6,r3,r4,r1,r5] is
      'S' -> rDiceStep [r5,r1,r3,r4,r6,r2] is
    rDiceStep st _ = st
    in rDiceStep [1..6] insts

main :: IO ()
main = do
  dice <- words <$> getLine
  insts <- getLine
  putStrLn $ dice !! ((head (rDice insts)) - 1)