def solve_chess_puzzle(gx: int, gy: int) -> int: # Base case - already at target if gx == 0 and gy == 0: return 0 # Rook (Luke) moves # Can reach in 1 move if target is on same row/column # Otherwise needs 2 moves (horizontal + vertical) rook_moves = 1 if gx == 0 or gy == 0 else 2 # Bishop moves # Can reach in 1 move if target is on diagonal (|x| = |y|) # Otherwise needs 2 moves bishop_moves = 1 if abs(gx) == abs(gy) else 2 return min(rook_moves, bishop_moves) def main(): # Read input as space-separated integers try: gx, gy = map(int, input().strip().split()) result = solve_chess_puzzle(gx, gy) # Ensure output is a single integer print(result) except ValueError: print("Invalid input format") if __name__ == "__main__": main()