import math def isok(n): ans=n-n//A-n//B+n//math.lcm(A,B) if ans1: mid=(right+left)//2 if isok(mid): left=mid else: right=mid print(right)