{-
 - `chebyshev n' returns the number of primes between n+1 and 2n.
 - e.g.:
 -   chebyshev 10 == 4    -- 11, 13, 17, 19
 -   chebyshev 13 == 3    -- 17, 19, 23
 -}

import Control.Monad  -- when

chebyshev :: Int -> Int
chebyshev n = length [x | x<-[n+1 .. 2*n], prime x]
 
prime :: Int -> Bool
prime n | n >= 2 = [x | x<-fs, n`mod`x == 0] == []
  where fs = takeWhile (\x->x*x <= n) ([2] ++ [3,5..])
                         -- x*x is faster than x^2

main :: IO ()
main = do n <- readLn
          when (n /= 0) $ do
            print (chebyshev n)
            main