import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  let
    s = sq n
  print . sum . map toInteger . map (pred . fst) . filter ((== 0) . snd) . map (divMod n) $ [1..s]
  
sq :: Int -> Int
sq n = sq' 0 ((n + 1) `div` 2)
  where
    sq' a b | b == a + 1 = a
            | m ^ 2 >= n = sq' a m
            | otherwise = sq' m b
      where
        m = (a + b) `div` 2

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
