def gcd(*numbers: int) -> int: if len(numbers) == 1: return numbers[0] if len(numbers) == 2: a, b = numbers if a < b: a, b = b, a while True: if a % b == 0: return b a, b = b, a % b first_gcd = gcd(*numbers[:2]) return gcd(first_gcd, *numbers[2:]) def main(): A, B = map(int, input().split()) AB_gcd = gcd(A, B) print(AB_gcd) if __name__ == "__main__": main()