#include <iostream>
#include <vector>

using namespace std;

bool isPrime(int n)
{
	for(int i = 2; i < n; i++)
		if((n%i)==0)
			return false;
	return true;	
}

int main()
{
	int n = 0;
	
	
	while(true)
	{
		cin>>n;

		if(n == 0)
			break;

		vector <int> myArray;
		int c = 0;

		for (int i = 2; i < n; i++)
			if(isPrime(i) == true)
				myArray.push_back(i);

		for(int j = 0; j < myArray.size(); j++)
			for(int k = j; k < myArray.size(); k++)
				if((myArray[j] + myArray[k]) == n)
					c++;

		cout<<c<<endl;
	}
	
	return 0;
}