#include <iostream>
#include <vector>
using namespace std;

int main( void )
{
	// prime numbers table
	vector <bool> isPrime( 60000 + 1, false );
	isPrime[2] = true;
	for ( int i = 3; i < 60000; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( int i = 3; i < 60000; i += 2 )
	{
		for ( int j = i + i; j < 60000; j += i )
		{
			isPrime[j] = false;
		}
	}

	vector <int> primes;
	primes.push_back( 2 );
	for ( int i = 3; i < 60000; i += 2 )
	{
		if ( isPrime[i] )
			primes.push_back( i );
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( int i = 0; i < primes.size(); i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime.at( n-primes[i] ) )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

}