-- | Main entry point to the application.
module Main where

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

rInt :: String -> Int
rInt str = read str :: Int

gcdm a b
    | a < b = gcdh a b
    | otherwise = gcdh b a

gcdh a b
    | b == 0 = a
    | otherwise = gcdh b (a `mod` b)

-- | The main entry point.
main :: IO ()
main = do
    [a,b] <- (map rInt . words) <$> getLine
    putStrLn . show $ gcdm a b