
$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

def count_answer(n)
  count = 0
  i = 1
  while true
    count += 1 if $primes.include?(n-$primes[i])
    i += 1
    break if n/2 < $primes[i]
  end
  puts count
end

loop do
  n = gets.to_i
  make_prime(n)
  break if n == 0
  if n.odd?
    puts 0
  else
    count_answer(n)
  end
end