import sys args = sys.argv A = int(args[1]) B = int(args[2]) for x in range(1, 100000): if x % A == B % x: print(x) break