require "prime"

loop {
    n = gets.to_i
    break if n == 0
    a = Prime.each(n).to_a
    i = 0
    j = a.size-1
    count = 0
    loop {
        j -= 1 until a[i] + a[j] <= n
        break if j < i
        count += 1 if a[i] + a[j] == n
        i += 1
        break if j < i
    }
    p count
}