import           Control.Applicative
import           Control.Monad

gcd' :: Int -> Int -> Int
gcd' x 0 = x
gcd' x y
    | x >= y    = gcd' y (x `mod` y)
    | otherwise = gcd' x (y `mod` x)

main :: IO ()
main = do
    [x,y] <- fmap read . words <$> getLine :: IO [Int]
    print $ gcd' x y

