def min_moves_to_goal(gx: int, gy: int) -> int: # Rook if gx == 0 or gy == 0: rook_moves = 1 if gx != 0 or gy != 0 else 0 # (0,0)は0手 else: rook_moves = 2 # Bishop if (gx + gy) % 2 != 0: bishop_moves = float('inf') # 行けない elif gx == 0 and gy == 0: bishop_moves = 0 elif abs(gx) == abs(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))