#include <stdio.h>
#include <math.h>
#define SIZE 50000
int prime[SIZE];

int sosu ( int n ) {
	int i , lim = (int)(sqrt(n));
	for ( i = 2; i <= lim; i++ ) {
		if ( n % i == 0 ) return 0;
	}
	return n;
}

void tmp(void) {
	int i , j = 0;
	for ( i = 2; i < SIZE; i++ ) {
		if ( sosu(i) != 0 ) {
			prime[j] = sosu(i);
			j++;
		}
	}
	return;
}

int main (void) {
	int n , i , j;
	tmp();
	
	while ( 1 ) {
		int count = 0;
		scanf("%d",&n);
		if ( n == 0 ) break;
		
		for ( i = 0; prime[i] <= n / 2; i++ ) {
			for ( j = i; prime[j] <= n; j++ ) {
				if ( prime[i] + prime[j] == n ) {
					count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}