#!/usr/bin/env ruby
N = 50_000 # ??¢?´¢???????´???°?????????
elt = Array.new(N, 1)
primes = []

# ??¨????????????????????????
elt[0] = 0
elt[1] = 0

N.times do |i|
  next if elt[i].zero?
  primes << i
  k = i * 2
  while k < N
    elt[k] = 0
    k += i
  end
end

# while line = gets
#   n = line.chomp!.to_i
#   break if n.zero?
# 
#   cnt = 0
#   primes.each do |pr|
#     break if pr > n/2
#     cnt += 1 if primes.include?(n-pr)
#   end
#   puts cnt
# end