
import Data.Functor

rev :: Int -> Int
rev pos = 7 - pos

{- 初期状態。top, front, east-}
firstDice :: (Int, Int, Int)
firstDice = (1, 2, 3)


turn :: (Int, Int, Int) -> Char -> (Int, Int, Int)
turn (top, front, east) cmd = 
    case cmd of
      'N' -> (front     , rev top , east)
      'S' -> (rev front , top     , east)
      'E' -> (rev east  , front   , top )
      'W' -> (east      , front   , rev top)

top (t, _, _) = t

main :: IO ()
main = do
    nums <- map (\x -> read x::Int) . words <$> getLine
    cmds <- getLine
    print $ nums !! (top (foldl turn firstDice cmds) -1)