def min_moves(Gx, Gy): rook_moves = 0 if Gx == 0 and Gy == 0: rook_moves = 0 elif Gx == 0 or Gy == 0: rook_moves = 1 else: rook_moves = 2 if (Gx + Gy) % 2 != 0: bishop_moves = float('inf') elif Gx == Gy or Gx == -Gy: bishop_moves = 1 else: bishop_moves = 2 return min(rook_moves, bishop_moves) Gx = int(input()) Gy = int(input()) print(min_moves(Gx, Gy))