A,B=map(int, input().split()) res=A+B for i in range(A+1): if i>B: break x=2*i y=A+B-2*i res=min(res,abs(x-y)) print(res)