import System.IO

main :: IO ()
main = do
  str <- getLine
  let [x,y] = map (\x -> read x :: Int) $ words str
  print $ myGCD x y

myGCD :: Int -> Int -> Int
myGCD x 0 = x
myGCD x y = myGCD y $ mod x y