require 'prime'

primes = Prime.each(25000).to_a

until (n = gets.to_i) == 0
    res = 0
    if n.odd?
        puts Prime.prime?(n-2)?1:0
    else
        primes.each do |p|
            break if p > n/2+1
            res += (Prime.prime?(n - p))?1:0
        end
        puts res
    end
end