// Programmed by Dag Langmyhr (dag(a)ifi.uio.no)
// for the 2002 Nordic ACM programming contest.

import java.io.*;

class Goldbach {
    static final int MAX = 32768;   // = 2^15
    static boolean p[] = new boolean[MAX+1];

    // Use `Sieve of Eratosthenes' to find all primes up to MAX.
    static void findPrimes () {
	for (int i1 = 2;  i1 <= MAX;  ++i1) p[i1] = true;
	p[1] = false;  // by definition.

	final int SQRTMAX = (int)Math.sqrt(MAX);
	for (int i1 = 2;  i1 <= SQRTMAX;  ++i1) {
	    if (! p[i1]) continue;
	    for (int i2 = 2*i1;  i2 <= MAX;  i2 += i1) p[i2] = false;
	}
    }

    static int findPairs (int x) {
	int n = 0;
	final boolean DEBUG = false;

	for (int ix = 2;  2*ix <= x; ++ix) {
	    if (p[ix] && p[x-ix]) {
		++n;
		if (DEBUG) 
		    System.err.println(ix + " + " + (x-ix) + " = " + x);
	    }
	}
	return n;
    }

    public static void main (String arg[]) throws Exception {
	findPrimes();

	BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
	String line;
	while (true) {
	    line = inp.readLine();
	    int n = Integer.parseInt(line);
	    if (n == 0) break;
	    System.out.println(findPairs(n));
	}
    }
}
