def sieve(n)
  ps = Array.new(n + 1, true)
  ps[0] = false
  ps[1] = false

  2.upto(n-1) do |i|
    next unless ps[i]

    k = 2
    while k * i <= n
      ps[k * i] = false
      k += 1
    end
  end

  ps
end

def solve(n, ps)
  ans = 0
  2.upto(n/2) do |a|
    b = n - a
    ans += 1if ps[a] && ps[b]
  end
  ans
end

ps = sieve(50000)

while true
  n = gets.to_i
  break if n == 0
  puts solve(n, ps)
end