module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [Int] -> String -> Int
solve pl = sim (listArray (0, 5) pl) where
    sim dice [] = dice!0
    sim dice (c:cs) = sim roll cs where
        roll = case c of
            'N' -> dice // [(0, dice!1), (1, dice!5), (4, dice!0), (5, dice!4)]
            'E' -> dice // [(0, dice!3), (2, dice!0), (3, dice!5), (5, dice!2)]
            'W' -> dice // [(0, dice!2), (2, dice!5), (3, dice!0), (5, dice!3)]
            'S' -> dice // [(0, dice!4), (1, dice!0), (4, dice!5), (5, dice!1)]
                
readLine:: IO [Int]
readLine = fmap (map read . words) getLine

main :: IO() 
main = do
    pl <- readLine
    cl <- getLine
--    print pl
--    print cl
    print (solve pl cl)

