prime = Array.new(50001, true)
for i in 2..50000 ** 0.5
  if prime[i]
    for j in 2..50000 / i
      prime[i * j] = false
    end
  end
end
prime[0], prime[1] = false, false
while (n = gets.to_i) != 0
  sum = 0
  for i in 2..n / 2
    if prime[i] and prime[n - i]
      sum += 1
    end
  end
  puts sum
end