#include <cstdio>
#include <vector>

using namespace std;

const int SIEVE_SIZE = 1000000;

bool sieve[SIEVE_SIZE + 1];

int main()
{
	int n;
	int i,j,cnt;
	vector<int> prime;
	
	sieve[0] = sieve[1] = true;
	for (i = 2; i * i <= SIEVE_SIZE; i++){
		if (sieve[i]) continue;
	   	for (j = i*i; j <= SIEVE_SIZE; j += i){
	    	 sieve[j] = true;
	    }
	}
	
	for (i = 0; i < SIEVE_SIZE; i++){
		if (!sieve[i]){
			prime.push_back(i);
		}
	}
	
	int num = prime.size();
	int sum;
	
	while (scanf("%d", &n), n != 0){
		cnt = 0;
		for (i = 0; n/2 >= prime[i]; i++){
			for (j = 0; prime[j] < n; j++){
				if (prime[i] + prime[j] == n) cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
}