def prime(n)
  primes = Array.new(n + 1){|i|i}
  primes[1] = nil
  for i in 2..n ** 0.5
    if primes[i]
      for j in 2..n / i
        primes[i * j] = nil
      end
    end
  end
  return primes[2..-1].select{|f|f}
end
def main(input = STDIN)
  primes = prime(50000)
  num = Array.new(50001, 0)
  primes.each_with_index{|i, idx|
    while primes[idx] and primes[idx] + i <= 50000
      num[i + primes[idx]] += 1
      idx += 1
    end
  }
  while (n = input.gets.to_i) != 0
    puts num[n]
  end
end
main