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 $ f [] cs rcs
  where
    pns = 2 : sieve [3,5..]
    cs = takeWhile (<= x) pns
    rcs = reverse cs
    f :: [Int] -> [Int] -> [Int] -> [Int]
    f acc [] _ = acc
    f acc _ [] = acc
    f acc (n:ns) (m:ms) | n > m = acc
                        | n + m == x = f (n:acc) ns ms
                        | n + m < x = f acc ns (m:ms)
                        | n + m > x = f acc (n:ns) ms
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