// Aizu 1200: Goldbach's Conjecture
// 2017.9.16 bal4u@uu
#include <stdio.h>

#define MAX  32768	 // 2^15
#define SQRT 181     // sqrt(MAX)
char prime[MAX + 3], *p, *q, *pmax = prime + MAX;

void mkprime()
{
	int k;
	prime[1] = 1;
//	for (p = prime + 4; p <= pmax; p += 2) *p = 1;
	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2)
		if (!*p) for (q = p + k; q <= pmax; q += k) *q = 1;
}

int main()
{
	int n, m, p, ans;

	mkprime();
	while (scanf("%d", &n) && n) {
		if (n == 4) ans = 1;
		else for (ans = 0, m = n >> 1, p = 3; p <= m; p += 2) if (!prime[p] && !prime[n - p]) ans++;
		printf("%d\n", ans);
	}
	return 0;
}