import Control.Applicative
import Data.Tuple

--          ([前, 後], [左, 右], [上, 下])
type Dice = [(String, String)]

makeDice :: [String] -> Dice
makeDice ls = map (\(x, y) -> (ls' !! x, ls' !! y)) di
  where
    ls' = "_" : ls
    di = [(2, 5), (4, 3), (1, 6)]

rotate :: Dice -> Char -> Dice
rotate [xs, ys, zs] s
  | s == 'S' = [zs, ys, swap xs]
  | s == 'N' = [swap zs, ys, xs]
  | s == 'E' = [xs, swap zs, ys]
  | s == 'W' = [xs, zs, swap ys]

solve :: Dice -> String -> String
solve ds cmds = fst $ (foldl rotate ds cmds) !! 2


main :: IO ()
main = do
  labels <- words <$> getLine
  cmds   <- getLine
  putStrLn $ solve (makeDice labels) cmds

