max = 50000
prime = [2]
list = Array.new(max){|i| i}
list[0] = 0
list[1] = 0
loop do
  a = prime[-1]
  break if a >= Math.sqrt(max)
  i = a
  while i <= max
    list[i] = 0
    i += a
  end
  while list[a] == 0
    a += 1
  end
  prime << list[a]
  list[a] = 0
end
prime += list - [0]

p = {}
prime.each{|i|
  p[i] = true
}

while n = gets.to_i
  break if n == 0
  count = 0
  i = 0
  loop do
    break if prime[i] > n / 2
    if p[n - prime[i]]
      count += 1
    end
    i += 1
  end
  puts count
end