import Control.Monad
import Control.Monad.State
import Data.List (foldl')

main = evalStateT solve primes

solve :: StateT [Int] IO ()
solve = do
  ps <- get
  n <- liftIO readLn
  unless (n == 0) $ do
    liftIO . print $ primeComsLen n 0 ps
    solve

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

primeComsLen n l (x:xs)
  | 2*x > n       = l
  | isPrime (n-x) = primeComsLen n (l+1) xs
  | otherwise     = primeComsLen n l xs