require 'prime'
cache = Array.new(50001,0)
ps = Prime.each(50000).to_a
while ps!=[]
	p = ps[0]
	ps.each do |x|
		if p+x < cache.length
			cache[p+x]+=1 
		else
			break
		end
	end
	ps.shift
end

while (n = gets.to_i) != 0
	p cache[n]
end