#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;



int main(){
	int n,count,prime[100000],u,check[50100];
	prime[0] = 2;
	count = 0;
	check[0]=0;
	check[1]=0;
	check[2]=1;
	for(int i=3;i<50100;i++){
		n=0;
		for(int j=0;prime[j]<=sqrt(i);j++){
			if(i%prime[j]==0)n++;
		}
		if(n==0){
			count++;
			prime[count] = i;
			check[i]=1;
		}
		else check[i] = 0;
	}
	
	while(1){
		count=0;
		u=1;
		cin >> n;
		if(n==0)break;
		for(int i=0;prime[i]*2<=n;i++){
			if(check[n-prime[i]]){
				count++;
			}
		}
		printf("%d\n",count);
		
	}
	return 0;
}
