n = 50000
sn = n**0.5 + 1
is_prime = [false, false] + [true] * (n - 1)

(2..sn).each do |i|
  next unless is_prime[i]
  (i*i).step(n, i).each do |j|
    is_prime[j] = false
  end
end

pl = (2..n).map.select{ |i| is_prime[i] }

while gets do
  s = $_.to_i
  break if s == 0
  count = 0

  tmp = pl.dup
  l = tmp.shift
  h = tmp.pop
  until tmp.empty? do
    if (l + h) == s
      count += 1
      l = tmp.shift
    elsif (l + h) > s
      h = tmp.pop
    else
      l = tmp.shift
    end
  end

  if l*2 == s or h*2 == s or (l + h) == s
    count += 1
  end
  puts count
end