import           Control.Applicative
import           Control.Monad
import           Data.List

rotate:: [Int] -> Char -> [Int]
rotate [u,f,r,l,b,d] 'E' = [l,f,u,d,b,r]
rotate [u,f,r,l,b,d] 'N' = [f,d,r,l,u,b]
rotate [u,f,r,l,b,d] 'S' = [b,u,r,l,d,f]
rotate [u,f,r,l,b,d] 'W' = [r,f,d,u,b,l]
rotate xs _              = xs

main :: IO ()
main = do
  dice <- map read . words <$> getLine
  opts <- getLine
  print (head $ foldl rotate dice opts)
