A,B=map(int, input().split()) s=2*min(A,B) t=A+B-s ans=abs(s-t) for i in range(min(A,B)): s-=2 t+=2 ans=min(ans,abs(s-t)) print(ans)