import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

data Dice = Dice 
  { top :: Int
  , bottom :: Int
  , north :: Int
  , south :: Int
  , east :: Int
  , west :: Int
  }

main :: IO ()
main = do
  [t,s,e,w,n,b] <- readInts
  xs <- getLine
  let d0 = Dice t b n s e w
  let d1 = foldl rotate d0 xs
  print $ top d1

rotate :: Dice -> Char -> Dice
rotate d@(Dice t b n s e w) 'N' = d { top = s, north = t, south = b, bottom = n }
rotate d@(Dice t b n s e w) 'S' = d { top = n, north = b, south = t, bottom = s }
rotate d@(Dice t b n s e w) 'E' = d { top = w, east = t, west = b, bottom = e }
rotate d@(Dice t b n s e w) 'W' = d { top = e, east = b, west = t, bottom = w }

