import java.util.Scanner

class PrimeList {

  private def sieve(xs: List[Int]): List[Int] =
    if (xs.isEmpty)
      Nil
    else
      xs.head :: sieve(xs.tail.filter(_ % xs.head != 0))

  private val primeList = sieve(Range(2, 1000000).toList)

  def isPrime(N: Int): Boolean = primeList.exists(N ==)

}

object Main {
  val primeList = new PrimeList

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      var count = 0
      for (i <- 2 to N / 2) {
        if (primeList.isPrime(i) && primeList.isPrime(N - i)) {
          count += 1
        }
      }
      println(count)
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}