#include <stdio.h>

int t[1000000], prime[100000];
int main(void)
{
	int n, i, j, count;	
	
	for (i = 2; i * i <= 1000000; i++){
		if (t[i] == 0){
			for (j = 2 * i; j <= 1000000; j++){
				if (j % i == 0){
					t[j] = 1;
				}
			}
		}
	}
	
	count = 0;
	for (i = 2; i < 1000000; i++){
		if (t[i] == 0){
			prime[count++] = i;
		}
	}
	
	while (scanf("%d", &n), n != 0){
		if (n % 2 == 1){
			printf("0\n");
			continue;
		}
		
		count = 0;
		for (i = 0; prime[i] <= n; i++){
			for (j = i; prime[j] <= n; j++){
				if (prime[i] + prime[j] == n){
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	
	return 0;
}