A, B = map(int, input().split()) a = A + B b = A * B if a < b: a, b = b, a while b > 0: r = a % b a = b b = r print(a)