import Data.Either
import Control.Applicative

data Op = S | E | N | W deriving (Show, Eq, Enum)

fromChar c | c == 'S' = S
           | c == 'E' = E
           | c == 'N' = N
           | c == 'W' = W
           | otherwise = error $ "Invalid char " ++ [c]

fromString [] = []
fromString (x:xs) = (fromChar x):(fromString xs)

data Dice = Dice { top :: Int, front :: Int, right :: Int, left :: Int, back :: Int, bottom :: Int }
  deriving (Show, Eq)

makeDice [t, f, r, l, ba, bo] = Dice t f r l ba bo

roll S (Dice t f r l ba bo) = Dice ba t r l bo f
roll N (Dice t f r l ba bo) = Dice f bo r l t ba
roll E (Dice t f r l ba bo) = Dice l f t bo ba r
roll W (Dice t f r l ba bo) = Dice r f bo t ba l
rolls [] dice = dice
rolls (x:xs) dice = rolls xs (roll x dice)


main = do
  labels <- map read . words <$> getLine :: IO [Int]
  ops <- fromString <$> getLine :: IO [Op]
  print . top . rolls ops . makeDice $ labels


