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

while gets
  s = $_.to_i
  break if s == 0
  tmp = plist.dup
  l = tmp.shift
  h = tmp.pop
  c = 0

  until tmp.empty?
    if l + h == s
      c += 1
      l = tmp.shift
    elsif l + h < s
      l = tmp.shift
    else
      h = tmp.pop
    end
  end

  c += 1 if l*2 == s or h*2 == s or l+h == s
  puts c
end