import java.util.Scanner

class PrimeList {
  private def createList(N: Int): List[Int] = {
    if (N <= 2)
      List(2)
    else {
      val prev = createList(N - 2)
      if (prev.exists(a => N % a == 0))
        prev
      else
        prev :+ N
    }
  }

  private val primeList = createList(100001)

  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)
  }
}