def min_difference(A, B): if A > B: A, B = B, A if B <= 2 * A: return (B - A) % 2 else: return B - 3 * A A, B = map(int, input().split()) print(min_difference(A, B))