import Control.Applicative
import Data.Function
import Control.Monad
import Data.List
import Data.Char
import Text.Printf

type Dice = [Int]

rotate :: String -> Dice -> Dice
rotate [] dice = dice
rotate ('W':xs) [a,b,c,d,e,f] = rotate xs [c,b,f,a,e,d]
rotate ('E':xs) [a,b,c,d,e,f] = rotate xs [d,b,a,f,e,c]
rotate ('S':xs) [a,b,c,d,e,f] = rotate xs [e,a,c,d,f,b]
rotate ('N':xs) [a,b,c,d,e,f] = rotate xs [b,f,c,d,a,e]

main :: IO ()
main = do
    d <- map read . words <$> getLine
    c <- getLine
    putStrLn . show $ head $ rotate c d
