#include<iostream>

int n;
int p;
bool isprime[50001];
int prime[50001];

void sieve( int x )
{
 	p = 0;
	
	isprime[0] = isprime[1] = false;
	for( int i = 2; i <= x; i++ ) isprime[i] = true;
	
	for( int i = 2; i <= x; i++ ){
	 	if( isprime[i] ){
			prime[p++] = i;
			
			for( int j = i * 2; j <= x; j += i ) isprime[j] = false;
		}
	}
}

int main()
{
	sieve( 50000 );

	while( 1 ){
		std::cin >> n;
		if( !n ) break;
		
		int ans = 0;
		
		for( int i = 0; i < p; i++ ){
			for( int j = i; j < p; j++ ){
				if( prime[i] + prime[j] == n ) ans++;
			}
		}
		
		std::cout << ans << std::endl;
	}
	
 	return 0;
}