mygcd :: Int -> Int -> Int
mygcd x y
    | r == 0    = y
    | otherwise = gcd y r
        where r = x `mod` y

solve :: [Int] -> String
solve [x, y] = (show $ mygcd x y) ++ "\n"

main :: IO ()
main = interact (solve . map read . words)