def min_moves(Gx, Gy): if Gx == 0 and Gy == 0: rook_steps = 0 elif Gx == 0 or Gy == 0: rook_steps = 1 else: rook_steps = 2 if (Gx + Gy) % 2 != 0: bishop_steps = float('inf') elif Gx == 0 and Gy == 0: bishop_steps = 0 elif abs(Gx) == abs(Gy): bishop_steps = 1 else: bishop_steps = 2 return min(rook_steps, bishop_steps) Gx, Gy = map(int, input().split()) min_moves(Gx, Gy)