#include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class PrimeTest{
private:
	std::vector<bool> is_prime_;					//nが素数かどうかをis_prime[n]で判定
	std::vector<unsigned int> prime_numbers_;		//素数の集合

public:
	PrimeTest();

	~PrimeTest();

	const std::vector<unsigned int>& get_prime_numbers() const;

	bool is_prime(unsigned int n);

};

PrimeTest::PrimeTest(){
	is_prime_.push_back(false);	//0
	is_prime_.push_back(false);	//1
	is_prime_.push_back(true);	//2
	is_prime_.push_back(true);	//3

	prime_numbers_.push_back(2);
	prime_numbers_.push_back(3);
}
PrimeTest::~PrimeTest(){}

const std::vector<unsigned int>& PrimeTest::get_prime_numbers() const{
	return prime_numbers_;
}

bool PrimeTest::is_prime(unsigned int n){
	if(n >= is_prime_.size()){
		unsigned int i_s = is_prime_.size();
		is_prime_.resize(n + 1, false);

		//i_sからnまでの各数が素数かどうか判定
		for(unsigned int i = i_s; i <= n; i++){
			unsigned int max_val = int(sqrt((double)i));
			bool b = true;
			for(unsigned int j = 0; j < prime_numbers_.size(); j++){
				if(prime_numbers_[j] > max_val){ break;}
				if(i % prime_numbers_[j] == 0){
					b = false;
					break;
				}
			}
			if(b){
				prime_numbers_.push_back(i);
				is_prime_[i] = true;
			}
		}

	}
	return is_prime_[n];
}

int main(){
	PrimeTest prime_test;
	int n;
	int result;
	std::vector<unsigned int> prime_numbers;

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif

	prime_test.is_prime(50000);
	prime_numbers = prime_test.get_prime_numbers();

#if INPUT_FROM_FILE
	while(fscanf(fp, "%d", &n) != EOF){
#else
	while(scanf("%d", &n) != EOF){
#endif
		if(n == 0){ break; }
		result = 0;
		for(int i = 0; i < prime_numbers.size(); i++){
			if(prime_numbers[i] > n){ break; }
			int m = n - prime_numbers[i];

			if(std::binary_search(prime_numbers.begin() + i, prime_numbers.end(), m)){
				result++;
			}
		}
		printf("%d\n", result);
	}

#if INPUT_FROM_FILE
	fclose(fp);
#endif
	return 0;
}
