import           Control.Applicative
import           Control.Monad
import           Data.List
import           Text.Printf

gcd' :: Integer -> Integer -> Integer
gcd' a 0 = a
gcd' a b = gcd' b (a `mod` b)

main = do
    [n,m]<- map (read::String->Integer) . words <$> getLine
    print $ gcd' n m

