require 'prime'
$primes = (2..50000).select(&:prime?)

def count_answer(n)
  count = 0
  i = 1
  ceil = n/2
  while $primes[i] <= ceil
    count += 1 if (n-$primes[i]).prime?
    i += 1
  end
  count
end

loop do
  n = gets.to_i
  break if n == 0
  if n.odd?
    puts 0
  else
    puts count_answer(n)
  end
end