getSmall x y = if x < y then x else y solve [x,y,d] | d == 0 = 1 | x < d && y < d = 0 | x' == y' = x' + 1 | otherwise = ans + 1 where x' = getSmall x d y' = getSmall y d ans = getSmall x' y' main = do xyd <- map (abs . read :: String -> Int) . words <$> getLine print $ solve xyd