gcd' :: Int -> Int -> Int
gcd' m n
  | n == 0 = m
  | otherwise = gcd' n (m `mod` n)

main :: IO ()
main = do
    xs <- getLine
    let xs' = words xs
        xs'' = map (\x -> read x :: Int) xs'
     in print $ gcd' (head xs'') (xs'' !! 1)