module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [Int] -> Int
solve [a, b] | a > b = iter b a
             | otherwise = iter a b where
    iter x 0 = x
    iter x y = iter y (mod x y)

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

main :: IO() 
main = do
    l <- readLine
    print (solve l)

