type Dice = [(Int, Int)]

toDice :: [Int] -> Dice
toDice [a, b, c, d, e, f] = [(a, f), (b, e), (c, d)]

toList :: Dice -> [Int]
toList [(a, f), (b, e), (c, d)] = [a, b, c, d, e, f]

swap :: (a, a) -> (a, a)
swap (a, b) = (b, a)

roll :: Dice -> Char -> Dice
roll [a, b, c] dir = case dir of
  'N' -> [b, swap a, c]
  'E' -> [swap c, b, a]
  'S' -> [swap b, a, c]
  'W' -> [c, b, swap a]
  _   -> [a, b, c]

main = do
  d <- return . toDice . map (\x -> read x :: Int) . words =<< getLine
  print . head . toList . foldl roll d =<< getLine