-- `chebyshev n' returns the number of primes between n+1 and 2n.
-- for example:
--   chebyshev 10 == 4   (11, 13, 17, 19)
--   chebyshev 13 == 3   (17, 19, 23)

chebyshev :: Int -> Int
chebyshev n = length $ filter isPrime [n + 1 .. 2 * n]

isPrime :: Int -> Bool
isPrime n = and $ map (\d -> mod n d /= 0) divisors
  where
    divisors = takeWhile (\d -> d * d <= n) ([2] ++ [3,5..])

main :: IO ()
main = do
  n <- readLn
  if n == 0
     then return ()
     else do print $ chebyshev n
             main