import sys def min_moves_to_goal(Gx: int, Gy: int) -> int: # Rook moves if Gx == 0 and Gy == 0: rook = 0 elif Gx == 0 or Gy == 0: rook = 1 else: rook = 2 # Bishop moves if Gx == 0 and Gy == 0: bishop = 0 elif Gx == Gy or Gx == -Gy: bishop = 1 else: bishop = 2 return min(rook, bishop) def main(): data = sys.stdin.read().split() if len(data) < 2: return Gx, Gy = map(int, data) print(min_moves_to_goal(Gx, Gy)) if __name__ == "__main__": main()