import Control.Applicative

-- Top, Front, Right. Back, Left, Bottom
-- X: Right-Left, Y: Front-Back, Z: Top-Bottom
type Dice a = (a,a,a,a,a,a)

rollPX :: Dice a -> Dice a
rollPX (tp,fr,rg,bk,lf,bt) = (fr,bt,rg,tp,lf,bk)

rollNX :: Dice a -> Dice a
rollNX (tp,fr,rg,bk,lf,bt) = (bk,tp,rg,bt,lf,fr)

rollPY :: Dice a -> Dice a
rollPY (tp,fr,rg,bk,lf,bt) = (lf,fr,tp,bk,bt,rg)

rollNY :: Dice a -> Dice a
rollNY (tp,fr,rg,bk,lf,bt) = (rg,fr,bt,bk,tp,lf)

rollPZ :: Dice a -> Dice a
rollPZ (tp,fr,rg,bk,lf,bt) = (tp,rg,bk,lf,fr,bt)

rollNZ :: Dice a -> Dice a
rollNZ (tp,fr,rg,bk,lf,bt) = (tp,lf,fr,rg,bk,bt)

rollX :: Int -> Dice a -> Dice a
rollX n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPX)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNX))

rollY :: Int -> Dice a -> Dice a
rollY n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPY)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNY))

rollZ :: Int -> Dice a -> Dice a
rollZ n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPZ)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNZ))

main = do
  [d1,d2,d3,d4,d5,d6] <- map read . words <$> getLine :: IO [Int]
  s <- getLine

  let
    dice = (d1,d5,d3,d2,d4,d6)
    rotate = foldl (.) id $ (flip map) (reverse s) $ \c -> case c of
                                    'S' -> rollPX
                                    'N' -> rollNX
                                    'E' -> rollPY
                                    'W' -> rollNY

    (top,_,_,_,_,_) = rotate dice

  print top

