$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.even?
	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

def next_primep(n)
	n += 2
	loop do
		return n if is_prime?(n)
		n += 2
	end
end

while true
	n = gets.to_i
	make_prime(n/2)
	break if n == 0
	if n.odd?
		puts 0
		next
	end
	count = 0
	p = 3
	while true
		count += 1 if is_prime?(n-p)
		p = next_primep(p)
		break if n/2 < p
	end
	puts count
end