require 'prime'

h = {}
primes = Prime.each(25000).to_a
primes.each {|pr| h[pr] = true}
until (n = $<.gets.to_i).zero?
  co = 0
  if n.odd?
    co = 1 if h[n - 2]
  else
    primes.each do |pr|
      break if pr > n / 2
      co += 1 if h[n - pr]
    end 
  end
  puts co
end
