#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ElapsedTime{
	chrono::system_clock::time_point m_start;
public:
	ElapsedTime(){
		m_start = chrono::system_clock::now();
	}
	~ElapsedTime(){
		const auto end = chrono::system_clock::now();
		const auto elapsed = chrono::duration_cast<std::chrono::milliseconds >(end - m_start).count();
		out(elapsed,"ms");
	}
};

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	map<int,int> M;
	auto P=enum_prime(50000);
	for(int i=0,ei=P.size();i<ei;i++){
		for(int j=i;j<ei;j++){
			M[P[i]+P[j]]++;
		}
	}

	while(true){
		int N=in();
		if(!N) break;
		out(M[N]);
	}
	return 0;
}
