import           Control.Applicative
import           Data.List

newtype Dice =
    Dice [Int]
    deriving (Eq, Show)

dice :: Dice
dice = Dice [0,1,2,3,4,5]

roll :: Char -> Dice -> Dice
roll 'E' (Dice ds) = Dice [ds !! (i-1) | i <- [4,2,1,6,5,3]]
roll 'N' (Dice ds) = Dice [ds !! (i-1) | i <- [2,6,3,4,1,5]]
roll 'S' (Dice ds) = Dice [ds !! (i-1) | i <- [5,1,3,4,6,2]]
roll 'W' (Dice ds) = Dice [ds !! (i-1) | i <- [3,2,6,1,5,4]]

main :: IO ()
main = do
    xs <- fmap read . words <$> getLine :: IO [Int]
    cs <- getLine :: IO [Char]
    let ds = foldl' (\d f -> f d) dice (fmap roll cs)
    case ds of
        Dice (a:as) -> print (xs !! a)

