#include <iostream>
using namespace std;

/** Problem0056 : Goldbach's Conjecture **/
#define MAX 50000
int main()
{
	bool prime[MAX];
	int  input, count;
	
	for (int i=0; i<MAX; i++)
		prime[i] = true;
	
	prime[0] = false; prime[1] = false;
		
	for (int i=2; i<MAX; i++) {
		if (prime[i]) {
			for (int j=2; i*j<MAX; j++) {
				prime[i*j] = false;
			}
		}
	}
	
	while (1) {
		cin >> input;
		if (input == 0) break;
		
		count = 0;
		for (int i=input; i>1; i--) {
			if (!prime[i]) continue;
			for (int j=input; j>=i; j--) {
				if (!prime[j]) continue;
				if (i+j==input) count++;
			}
		}
		
		cout << count << endl;
	}
	
	return 0;
}