import Control.Applicative
import Control.Monad

gcd' x 0 = x
gcd' x y
    | x > y     = gcd' y ( mod x y )
    | otherwise = gcd' x ( mod y x )

main = do 
    (x:y:_) <- (map read.words) <$> getLine
    putStrLn $ show(gcd' x y)