import Control.Applicative

type Dice
    = (Int, Int, Int, Int, Int, Int)

type Rolling
    = [Char]

type Problem
    = (Dice, Rolling)

type Result
    = Dice

roll :: Dice -> Char -> Dice

roll (s1, s2, s3, s4, s5, s6) char
    = case char of
        'N' -> (s2, s6, s3, s4, s1, s5)
        'S' -> (s5, s1, s3, s4, s6, s2)
        'E' -> (s4, s2, s1, s6, s5, s3)
        'W' -> (s3, s2, s6, s1, s5, s4)

solve :: Problem -> Result

solve (dice, rolling)
    = foldl roll dice rolling

output :: Result -> String

output (s1, _, _, _, _, _)
    = show s1
    
input :: IO Problem

input
    = do
        [s1, s2, s3, s4, s5, s6] <- map read.words <$> getLine
        rolling <- getLine
        return ((s1, s2, s3, s4, s5, s6), rolling)

main :: IO ()

main
    = putStrLn.output =<< solve <$> input