main :: IO ()
main = do
    dice <- fmap words getLine
    coms <- getLine
    putStrLn . head $ foldl role dice coms

role :: [String] -> Char -> [String]
role [a,b,c,d,e,f] com
    | com == 'E' = [d,b,a,f,e,c]
    | com == 'N' = [b,f,c,d,a,e]
    | com == 'S' = [e,a,c,d,f,b]
    | com == 'W' = [c,b,f,a,e,d]
