a,b=map(int,input().split()) if a>b: print(2000000000-a) else: print(a-1)