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