A,B = map(int,input().split()) ok = 0 ng = 0 while (A > 0) and (B > 0): ng += 2 A -= 1 B -= 1 if A+B < 2: break if A > B: A -= 2 elif B > A: B -= 2 else: A -= 1 B -= 1 ok += 2 ok += A ok += B print(abs(ok-ng))