{-#LANGUAGE BangPatterns#-}
import Data.Functor

main::IO ()
main=do
  (x:y:_) <- map read . words <$> getLine ::IO [Int]
  print $ gcdEuclid x y

gcdEuclid::Integral a=>a->a->a
gcdEuclid x 0=x
gcdEuclid !x !y=gcdEuclid y (x `mod` y)