#include <iostream>
using namespace std;

#define NM (1<<16)

int prime[NM] = {0};

int main()
{
	prime[0] = prime[1] = 1;
	for(int i=2; i*i<NM; i++)
	{
		if(!prime[i])
		{
			for(int j=i*2; j<NM; j+=i)
			{
				prime[j] = 1;
			}
		}
	}

	int n,c;
	while(cin >> n, n)
	{
		c=0;
		for(int i=2; i<=n/2; i++)
		{
			if((!prime[i])&&(!prime[n-i])) c++; 
		}
		cout << c << endl;
	}
}