main = do x <- readLn y <- readLn l <- readLn print $ compute x y l compute :: Int -> Int -> Int -> Int {- compute x y l = inner (compare y 0) (compare x 0) where inner GT EQ = yl inner GT _ = yl + 1 + xl inner LT EQ = 2 + yl inner LT _ = 1 + xl + 1 + yl inner EQ EQ = 0 inner EQ _ = 1 + xl xl = steps x l yl = steps y l -} compute x y l = if y < 0 then xl + yl + 2 else if x == 0 then yl else xl + yl + 1 where xl = steps x l yl = steps y l steps x l = let (p,q) = divMod (abs x) l in if q == 0 then p else p+1