#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>

using namespace std;

void MakePrimeArray(bool A[],int n){
	
	A[0] = A[1] = false;
	for(int i=2;i<n;i++){
		A[i] = true;
	}
	
	for(int	i=2;i*i<n;i++){
	if(A[i]){
			for(int j=i*i;j<n;j+=i){
				A[j] = false;
			}
		}
	}
	
}



inline int GoldBach(vector<int> prime,int n){
	
	int count=0;
	deque<int> clear;
	bool ok=true;
	clear.push_back(0);
	/*for(int i=0;prime[i]<n;i++){
		ok=true;
		for(int k=0;k<clear.size();k++){
			if(prime[i]==clear[k]){
				ok=false;
				break;	
			}
		}
		if(ok){
			for(int j=i;prime[j]+prime[i]<=n;j++){
				if(!ok) break;
			
				if(prime[i]+prime[j] == n){
					count++;
					ok=false;
					clear.push_back(prime[j]);
				}
			}
		}
	}*/
	
	for(int i=0;prime[i]<n;i++){
		
		if(std::binary_search(clear.begin(), clear.end(), prime[i])){
			continue;
		}
		
		int num=n-prime[i];
		
	
		if(std::binary_search(prime.begin(), prime.end(), num)){
			count++;	
			clear.insert(clear.begin(),num);
		}
		
	}
	return count;
}

int main(){
	
	int n=50000;

	bool *primearray = new bool[n];
	
	MakePrimeArray(primearray,n);
	
	vector<int> prime;
	
	for(int i=2;i<n;i++){
		if(primearray[i]){
			prime.push_back(i);
		}
	}
	
	
	while(true){
		int innum;
		cin >> innum;
		
		if(innum==0) break;
		
		cout << GoldBach(prime,innum) << endl;
	}
	
	delete[] primearray;
	return 0;
}