A,B = [int(i) for i in input().split()] if A > B: print(2000000000-A) else: print(A-1)