import Control.Monad

main = do
  n <- readLn
  unless (n == 0) $ do
    print $ length $ primeComs n
    main

primeComs n = [ (i,j) | i <- takeWhile (\x -> 2*x <= n) $ primes,j <- [n-i], isPrime j]
primes :: [Int]
primes = 2 : filter isPrime [3,5..]
isPrime :: Int -> Bool
isPrime n = foldr ((&&).(/= 0).mod n) True $ takeWhile (<=sqrtn) primes
  where sqrtn = floor.sqrt.fromIntegral $ n