gx, gy = map(int, input().split()) def rook_moves(x, y): if x == 0 and y == 0: return 0 elif x == 0 or y == 0: return 1 else: return 2 def bishop_moves(x, y): if (x + y) % 2 != 0: return float('inf') # tidak bisa dicapai if x == 0 and y == 0: return 0 elif abs(x) == abs(y): return 1 else: return 2 rook = rook_moves(gx, gy) bishop = bishop_moves(gx, gy) print(min(rook, bishop))