#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	int a,count;
	bool f;
	vector<int> prime;
	vector<int>::iterator it,ite;
	f = true;
	prime.push_back(2);
	for(int i = 3;i <= 50000;++i){
		for(int j = 2;j <= sqrt(i);++j){
			if(i % j == 0) f = false;
		}
		if(f) prime.push_back(i);
		f = true;
	}
	while(cin >> a,a){
		count = 0;
		for(it = prime.begin();it != prime.end();){
			if(*it > a) break;
			for(ite = ++it;ite != prime.end();++ite){
				if(*it + *ite == a){
					++count;
				}
				else if(*it + *ite > a) break;
			}
		}
		cout << count << endl;
	}
	return 0;
}