a,b= map(int,input().split())

for i in range(21):
    if a*i == b:
        print(a+b)
        exit()
print(b-a) a,b= map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b for i in range(21):
    if a*i == b:
        print(a+b)
        exit() i range(21) range 21 if a*i == b:
        print(a+b)
        exit() a*i == b a*i a i b print(a+b) print a+b a b exit() exit print(b-a) print b-a b a b= map(int,input().split()) map(int,input().split()) b a,b= map(int,input().split()) map(int,input().split()) a
a,b= map(int,input().split())

for i in range(21):
    if a*i == b:
        print(a+b)
        exit()
print(b-a)
