type Dice = [Int]

roll :: Dice -> Char -> Dice
roll [a, b, c, d, e, f] direction =
  case direction of 
    'N' -> [b, f, c, d, a, e]
    'S' -> [e, a, c, d, f, b]
    'W' -> [c, b, f, a, e, d]
    'E' -> [d, b, a, f, e, c]

top :: Dice -> Int
top (x:xs) = x 

main :: IO ()
main = do
  dice <- map read . words <$> getLine :: IO [Int]
  commands <- getLine :: IO String
  print $ top $ foldl roll dice commands 