require "prime"

PrimeArray = (2..50000).select(&:prime?)

while input = $stdin.gets
  target = input.to_i
  break if target == 0
  
  source = PrimeArray.clone
  c = 0
  pl = 0
  pr = source.size - 1 
  while pl <= pr
    s = source[pl].to_i + source[pr].to_i
    if s > target
      pr -= 1
    elsif s == target
      c += 1
      pl += 1
    else
      pl += 1
    end 
  end
  
  puts c
end