
main = do
    x <- readLn
    print $ solve x 0 [0]

solve :: Int -> Int -> [Int] -> Int
solve x i ns =
    let i' = i + 1
        ns' = concat [[n-i', n, n+i'] | n <- ns]
    in if x `elem` ns' then i' else solve x i' ns'
