def min_moves_to_goal(gx: int, gy: int) -> int: # Rook hand count rook_moves = 1 if gx == 0 or gy == 0 else 2 # Bishop: same color check if (gx + gy) % 2 != 0: bishop_moves = float('inf') # bishop cannot reach elif gx == gy or gx == -gy: bishop_moves = 1 else: bishop_moves = 2 return min(rook_moves, bishop_moves) # 入力 gx, gy = map(int, input().split()) print(min_moves_to_goal(gx, gy))