import java.util.*

fun main(args:Array<String>):Unit {
    val prime = primes(35000)
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        println(
                prime.takeWhile{it * 2 <= n}.count{
                    prime.binarySearch(n - it) >= 0
                }
        )
    }
}
fun primes(upper:Int):Array<Int> {
    val stack = Stack<Int>()
    val isPrime = Array(upper + 1){it % 2 == 1}
    stack.push(2)
    for (i in 3 .. upper step 2){
        if (isPrime[i]){
            stack.push(i)
            if (i * i <= upper) for (j in i .. upper step i){
                isPrime[j] = false
            }
        }
    }
    return stack.toTypedArray()
}
