import Data.List (group)

-- | Generates the sequence of prime numbers.
-- Based on <http://qiita.com/little_Haskeller/items/614a3ae20a517c19bb1f this article> .
primes2 :: Integral a => [a]
primes2 = map fromIntegral primes2'
    where
        primes2' = [2, 3, 5] ++ sieve2 5 7 (drop 2 primes2')
        sieve2 m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ sieve2 (m * p) (p * p) ps
            where ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]]

-- | Factorizes the given integer using 'primes2'.
-- Based on <https://wiki.haskell.org/Testing_primality this page>.
factorize2 :: Integral a => a -> [a]
factorize2 1 = []
factorize2 n = factorize2' n primes2
    where
        factorize2' n ps@(p : pr)
            | p * p > n    = [n]
            | m == 0       = p : factorize2' d ps
            | otherwise    = factorize2' n pr
            where (d, m) = divMod n p

solve :: Int -> Int
solve l = (`div` 2) $ (1 +) $ product $
    map (\ek -> 2 * ek + 1) $ map length $ group $ factorize2 l

main :: IO ()
main = putStr . unlines . map show .
    map solve . takeWhile (/= 0) . map read . lines =<< getContents