import Data.List

main :: IO()
main = getContents >>= putStrLn.show.solve.formatIn

formatIn :: String -> [Int]
formatIn = reverse.sort.map read.words

solve    :: [Int] -> Int
solve [x,y] | x `mod` y == 0 = y
            | otherwise = solve [y, x `mod` y]