import Prelude main :: IO () main = do [x, y, l] <- map read . lines <$> getContents print $ calc x y l calc :: Int -> Int -> Int -> Int calc x y l = turns x y + over (abs x) l + over (abs y) l turns :: Int -> Int -> Int turns x y | x == 0 && y >= 0 = 0 | y >= 0 = 1 | otherwise = 2 over :: Int -> Int -> Int over x l = div x l + if mod x l == 0 then 0 else 1