import Data.Functor( (<$>))
import Data.List( foldl')

main = do
    initialDice <- (read <$>) . words <$> getLine   ::IO [Int]
    directions <- getLine
    let
	roll d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
	roll d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
	roll d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
	roll d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]

    print . head $ foldl' roll initialDice directions

