import Control.Applicative ((<$>))
import Data.Char (isSpace)
import Data.List (foldl', unfoldr)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

data Dice = Dice{
                    top    :: Int,
                    front  :: Int,
                    right  :: Int,
                    left   :: Int,
                    back   :: Int,
                    bottom :: Int
                }
                deriving (Show, Eq)

roll :: Dice -> Char -> Dice
roll (Dice top front right left back bottom) dir
    | dir == 'N' = Dice front bottom right left top back
    | dir == 'E' = Dice left front top bottom back right
    | dir == 'W' = Dice right front bottom top back left
    | dir == 'S' = Dice back top right left bottom front
    | otherwise  = Dice top front right left back bottom

rolls :: Dice -> String -> Dice
rolls d s = foldl' roll d s

getL :: (ByteString -> [Int]) -> IO [Int]
getL f = f <$> B.getLine

readIL :: (ByteString -> Maybe (Int, ByteString)) -> (ByteString -> [Int])
readIL f = unfoldr g
    where
        g s = do
            (n, s') <- f s
            return (n, B.dropWhile isSpace s')

main :: IO ()
main = do
    xs <- getL (readIL B.readInt)
    s  <- B.getLine
    print $ solve xs s

solve :: [Int] -> ByteString -> Int
solve xs s = top $ rolls (pasteNumToDice xs) (B.unpack s)

pasteNumToDice :: [Int] -> Dice
pasteNumToDice [a,b,c,d,e,f] = Dice a b c d e f
