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


data Dice = Dice{tp::Int, fr::Int, rt::Int, lt::Int, bk::Int, bm::Int} deriving (Show, Eq)

roll :: Dice -> Char -> Dice
roll (Dice tp fr rt lt bk bm) dir
  | dir == 'N' = Dice fr bm rt lt tp bk
  | dir == 'S' = Dice bk tp rt lt bm fr
  | dir == 'E' = Dice lt fr tp bm bk rt
  | dir == 'W' = Dice rt fr bm tp bk lt
  | otherwise = Dice tp fr rt lt bk bm

rolls :: Dice -> String -> Dice
rolls d s = foldl roll d s

initDice :: [Int] -> Dice
initDice [tp, fr, rt, lt, bk, bm] = Dice tp fr rt lt bk bm

main = do
  xs <- input (map read . words) :: IO [Int]
  s <- getLine
  print $ solve xs s

solve :: [Int] -> String -> Int
solve xs s = tp $ rolls (initDice xs) s

input :: (String -> a) -> IO a
input f = f <$> getLine