def checkPrime(number)
  return true if number == 2
  return false if number % 2 == 0
  i = 3
  while (i * i < number + 1)
    return false if number % i == 0
    i += 2
  end
  return true;
end

def getPrimeNums(max)
  prime = Array.new
  2.step(max, 1){|n| prime << n if checkPrime(n) }
  return prime
end

Prime = getPrimeNums(50000)

def getCombi(target)
  c = 0
  Prime.each{|a|
    Prime.each{|b|
      break if b > a
      c += 1 if a + b == target
    }
  }
  return c
end

loop do
  n = $stdin.gets.to_i
  break if n == 0
  p getCombi(n)
end