import Data.List
import Data.Array

erst :: Int->([Int],[Int])->[Int]
erst nmax (tosearch, primes)
    | x*x >= nmax  = sort $ primes' ++ tosearch'
    | otherwise    = erst nmax (tosearch', primes')
    where
        x = head tosearch
        tosearch' = [n|n<-(tail tosearch),(n`mod`x)/=0]
        primes' = primes ++ [x]

nmax = 50000
primes = erst nmax (filter odd [3..nmax], [2])
primes_b :: Array Int Bool
primes_b =  array (1,nmax) $ map (\i->(i,elem i primes)) [1..nmax]

solve::Int->Int
solve dat -- 4<=dat<=50000
    | odd dat    = if primes_b!(dat-2) then 1 else 0
    | otherwise  = length $ [n| n<-primes, n<=(dat-n) && primes_b!(dat-n)]

main::IO ()
main = do
    str<-getContents::IO String
    let input = takeWhile (/=0) . map (\x->read x::Int) . lines $ str
    mapM_ print $ map solve input