main = do
    dice <- getLine
    let (n1:n2:n3:n4:n5:n6:_) = map (\x -> read x :: Int) $ words dice
    commands <- getLine
    let finDice = roll commands (n1, n2, n3, n4, n5, n6)
    putStrLn $ top finDice

type Dice = (Int, Int, Int, Int, Int, Int)

roll :: String -> Dice -> Dice
roll [] dice = dice
roll (x:xs) dice
  | x == 'N' = roll xs $ rollN dice
  | x == 'E' = roll xs $ rollE dice
  | x == 'W' = roll xs $ rollW dice
  | x == 'S' = roll xs $ rollS dice
  | otherwise = dice

top :: Dice -> String
top (n1,_,_,_,_,_) = show n1

rollN :: Dice -> Dice
rollN (n1, n2, n3, n4, n5, n6) = (n2, n6, n3, n4, n1, n5)

rollE :: Dice -> Dice
rollE (n1, n2, n3, n4, n5, n6) = (n4, n2, n1, n6, n5, n3)

rollW :: Dice -> Dice
rollW (n1, n2, n3, n4, n5, n6) = (n3, n2, n6, n1, n5, n4)

rollS :: Dice -> Dice
rollS (n1, n2, n3, n4, n5, n6) = (n5, n1, n3, n4, n6, n2)
