#include <iostream>
#include <cmath>

bool isPrime(int n)
{
	int ub = (int)std::sqrt((float)n);
	for (int p=2; p<=ub; p++) {
		if (n%p==0) return false;
	}
	return true;
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n == 0) break;
		int res = 0;
		for (int k=3; k<=n/2; k++) {
			if (isPrime(k) && isPrime(n-k)) res++;
		}
		std::cout << res << std::endl;
	}
	return 0;
}

