sn = 50000.0**0.5.ceil
is_prime = [false, false] + [true]*(50000-1)
(2..sn).each do |i|
  next unless is_prime[i]
  (i*i).step(50000, i) do |j|
    is_prime[j] = false
  end
end
prime_list = (2..50000).to_a.select{ |i| is_prime[i] }

while n = gets.to_i do
  break if n == 0
  count = 0
  tmp = prime_list.dup
  l = tmp.shift
  h = tmp.pop
  until tmp.empty?
    if l + h == n
      count += 1
      l = tmp.shift
    elsif l + h < n
      l = tmp.shift
    elsif l + h > n
      h = tmp.pop
    end
  end
  count += 1 if l*2 == n or h*2 == n or l+h == n
  puts count
end