require 'prime'
readlines.each do |l|
  n = l.to_i
  break if n==0
  primes = (2..n).select(&:prime?)
  l = primes.shift
  h = primes.pop
  cnt = 0
  while !primes.empty?
    case
    when l+h==n; l = primes.shift; cnt += 1
    when l+h<n; l = primes.shift
    else h = primes.pop
    end
  end
  cnt += 1 if l*2==n || h*2==n
  puts cnt
end