#include<iostream>
#include<vector>

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;
			}
		}
	}
	
}

int GoldBach(vector<int> prime,int n){
	
	int count=0;
	int half=0;
	for(int i=0;prime[i]<n;i++){
		for(int j=0;prime[j]+prime[i]<=n;j++){
			if(prime[i]+prime[j] == n){
				count++;
				if(prime[i]!=prime[j])
					half++;
			}
		}
	}
	
	
	return count - half/2;
}

int main(){
	
	int n=50001;

	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;
	}
	
	return 0;
}