A,B=map(int,input().split()) ans=1<<30 for x in range(min(A,B)+1): ans=min(ans,abs(A+B-4*x)) print(ans)