import Data.Functor( (<$>))

main = do
    [x,y] <- (read <$>) . words <$> getLine	::IO [Int]
    let
	l = min x y
	g = max x y

	gcd x 0 = x
	gcd x y
	  = let
		r = x `rem` y
	    in
		gcd y r

    print $ gcd g l

