import Control.Applicative
data Dice = Dice {x1::Int,x2::Int,x3::Int,x4::Int,x5::Int,x6::Int} deriving Show
main = do
  s <- (map read . words) <$> getLine
  let d = Dice (s!!0) (s!!1) (s!!2) (s!!3) (s!!4) (s!!5 )
  op <- getLine
  putStrLn . show . x1 $ trans op d
  
trans :: [Char] -> Dice -> Dice
trans [] x = x
trans (x:xs) d = case x of 
  'E' -> trans xs (opE d)
  'W' -> trans xs (opW d)
  'N' -> trans xs (opN d)
  'S' -> trans xs (opS d)
  
opE :: Dice -> Dice
opE d = Dice (x4 d) (x2 d) (x1 d) (x6 d) (x5 d) (x3 d)

opW :: Dice -> Dice
opW d = Dice (x3 d) (x2 d) (x6 d) (x1 d) (x5 d) (x4 d)

opN :: Dice -> Dice
opN d = Dice (x2 d) (x6 d) (x3 d) (x4 d) (x1 d) (x5 d)

opS :: Dice -> Dice
opS d = Dice (x5 d) (x1 d) (x3 d) (x4 d) (x6 d) (x2 d)