#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	const int PrimeN = 50000;

	vector<int> primeList;
	bool used[PrimeN+2];
	
	memset(used, true, sizeof(used));

	for(int i = 2; i <= sqrt(PrimeN); i++)
	{
		if(used[i] == false)
		{
			continue;
		}
		for(int j = i*2; j <= PrimeN; j += i)
		{
			used[j] = false;
		}
	}
	for(int i = 2; i < PrimeN; i++)
	{
		if(used[i] == true)
		{
			primeList.push_back(i);
		}
	}
	int num, ans;
	while(cin >> num)
	{
		if(num == 0)
		{
			break;
		}
		ans = 0;

		for(int i = 0; i < primeList.size(); i++)
		{
			for(int j = i; j < primeList.size(); j++)
			{
				if(primeList[i] + primeList[j] == num)
				{
					ans++;
				}
			}
		}

		cout << ans << endl;
	}
}