import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  when (n /= 0) $ do
    print $ solve n
    main
  
solve :: Int -> Int
solve x = length [m | m <- ccs, (x - m) `elem` cs]
  where
    pns = 2 : sieve [3,5..]
    cs = takeWhile (<= x) pns
    ccs = takeWhile (\i -> i <= x - i) cs
    
sieve :: [Int] -> [Int]
sieve (p:ps) = p : [x | x <- sieve ps, x `mod` p /= 0]

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine