require 'prime'

ns = []
loop do
    n = gets.to_i
    break if n == 0
    ns << n
end

primes = Prime.each(ns.max).to_a

ns.each do |n|
    count = 0
    j = primes.size - 1
    (0..primes.size-1).each do |i|
        j -= 1 until primes[i] + primes[j] <= n
        break if j < i
        count += 1 if primes[i] + primes[j] == n
    end
    p count
end