import Control.Applicative

gcd' :: Int -> Int -> Int
gcd' x y
  | x < y     = gcd' y x
  | r == 0    = y
  | otherwise = gcd' y r
  where
      r = x `mod` y

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

