import Data.List(permutations) main :: IO () main = do n <- getLine print $ foldl gcd 0 $ (map read $ permutations n :: [Integer])