A, B = map(int, input().split()) a, b = A + B, A * B while a != b and min(a, b) > 0: if a > b: a %= b else: b %= a print(max(a, b))