import Control.Applicative

main = do
        [x,y] <- map read.words<$>getLine
        if x > y then print $ gcd' x y
                 else print $ gcd' y x

gcd' :: Int -> Int -> Int
gcd' x y
    | modXY == 0 = y
    | otherwise    = gcd' y modXY 
    where modXY = mod x y