$primes = [2,3]

def is_prime?(n)
	i = 0
	while $primes[i] <= Math.sqrt(n).to_i
		return false if n % $primes[i] == 0
		i += 1
	end
	return true
end

def next_prime(n)
	n += 1 if n % 2 == 0
	loop do
		return n if is_prime?(n)
		n += 2
	end
end

def make_prime(n)
	while $primes[-1] <= n
		$primes << next_prime($primes[-1]+1)
	end
end

make_prime(50000)
while true
	n = gets.to_i
	break if n == 0
	if n.odd?
		puts 0
		next
	end
	count = 0
	$primes.each do |x| 
		break if n/2 < x
		count += 1 if $primes.index(n-x)
	end
	puts count
end