#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> 
using namespace std;

bool is_prime[50001];
vector<int> prime;

void eratos(){
	fill(is_prime,is_prime+50001,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<=50000; ++i){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j=2; j*i<=50000; ++j) is_prime[j*i]=false;
		}
	}
}

int main(){
	int N;
	eratos();
	while(cin >> N&&N){
		int count=0;
		int size=prime.size();
		for(int i=0; i<size; ++i){
			if(prime[i]>=N) break;
			for(int j=0; j<=i; ++j){
				int sum=prime[i]+prime[j];
				if(N==sum) ++count;
				else if(N<sum) break;
			}
		}
		cout << count << endl;
	}
	return 0;
}