max = 50_000

primes = (2..Math.sqrt(max).ceil).inject([*2..max]) do |nums, sieve|
  nums.reject { |num| num % sieve == 0 && num != sieve }
end

while line = gets
  n = line.chomp.to_i
  break if n == 0

  answer = 0
  for i in 0..primes.size - 1
    break if primes[i] * 2 > n
    for j in i..primes.size - 1
      break if primes[i] + primes[j] > n
      answer += 1 if primes[i] + primes[j] == n
    end
  end

  puts answer
end