import Control.Monad
import Control.Applicative

main = do
    [a, b] <- map read . words <$> getLine
    putStrLn . show $ gcd' a b

gcd' :: Int -> Int -> Int
gcd' a 0 = a
gcd' a b = gcd b $ mod a b
