inf = 10**18 a,b = map(int, input().split()) if a>b: a,b = b,a if a*b==0: print(b); exit() ans = inf for i in range(a+1): for j in range(a+1): ans = min(ans, abs((i+j) - ((b-i)+(a-j)))) print(ans)