import Data.Set (toList, fromList, findMax, delete)
import Data.List (foldl')

main = interact $ unlines . map (show . goldbach . read) . init . lines

goldbach x
 | odd x = 0
 | otherwise = length [() | a<-p, b<-p, a+b == x, a<=b, a <= div x 2]
  where p = primes (2:[3,5..x])

primes = toList . (seive 2) . fromList  

seive p xs  
 | p*p > findMax xs = xs  
 | otherwise = seive (p+1) $ foldl' (\acc x -> delete x acc) xs [2*p,3*p..q]  
  where q = findMax xs  