def min_moves_to_reach(Gx, Gy): # Rook moves if Gx == 0 and Gy == 0: rook_moves = 0 elif Gx == 0 or Gy == 0: rook_moves = 1 else: rook_moves = 2 # Bishop moves if Gx == 0 and Gy == 0: bishop_moves = 0 elif (Gx + Gy) % 2 != 0: bishop_moves = float('inf') # Can't reach elif Gx == Gy or Gx == -Gy: bishop_moves = 1 else: bishop_moves = 2 # Choose the smaller of valid options return min(rook_moves, bishop_moves) # Input Gx, Gy = map(int, input().split()) # Output print(min_moves_to_reach(Gx, Gy))