#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int i,j,num=0,n,a=0,sum=0;
vector<int> x;
bool b(int m){
	sort(x.begin(),x.end());
	return binary_search(x.begin(),x.end(),m);
}
int main(){
	for(i=2;i<=50000;i++){
		for(j=2;j*j<=i;j++){
			if(i!=j){
				if(i%j==0){
					num=1;
					goto w;
				}}} w: if(num==0){x.push_back(i); a++;} num=0;
	}
	while(1){
		scanf("%d",&n);
		if(n==0) break;
	for(i=0;i<a;i++){
		if(x[i]<=n){if(b(n-x[i])) sum++;}
		else{goto y;}
	}y:
    if(sum%2==1) sum=sum/2+1;
	else sum=sum/2;
	printf("%d\n",sum); sum=0;
	}
	return 0;
}