import Data.Maybe (fromMaybe) minNumOps :: Integral a => a -> a -> Maybe a minNumOps x y | x == y = Just 0 | y == 0 = Just 1 | x == 0 = Just 2 | x == -y = Just 3 | otherwise = Nothing main :: IO () main = do [x, y] <- fmap read . words <$> getLine :: IO [Int] print $ fromMaybe (-1) (minNumOps x y)