import Control.Applicative
import Control.Monad
import Data.Vector.Unboxed.Mutable (IOVector, STVector)
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  pt <- VM.replicate mxv True
  VM.write pt 0 False
  VM.write pt 1 False
  forM_ [2 .. mxi] $ \i -> do
    b <- VM.read pt i
    when b $ do
      forM_ [i * i, i * i + i .. mxv - 1] $ \j -> do
        VM.write pt j False
  solve pt

mxv :: Int
mxv = 50000

mxi :: Int
mxi = 223

solve :: IOVector Bool -> IO ()
solve pt = do
  n <- readLn
  unless (n == 0) $ do
    foldM (f pt n) 0 [2 .. n `div` 2] >>= print
    solve pt
  where
    f pt n sm x = do
      b1 <- VM.read pt x
      b2 <- VM.read pt (n - x)
      if b1 && b2
         then return (sm + 1)
         else return sm

