n,k=map(int,input().split()) if n<=k: print(n) exit() ans=k if n%2==1: print(ans+1) else: print(ans)