#include<iostream>
using namespace std;
int main() {
	bool sosu[50000] = { false };
	for (int i = 2; i < 50000; ++i) {
		if (sosu[i] == false) {
			for (int k = i * 2; k < 50000; k += i) {
				sosu[k] = true;
			}
		}
	}
	int n;
	while (cin >> n &&n!= 0) {
		int answer = 0;
		if (n % 2) {
			(sosu[n - 2] == true) ? cout << 0 << endl : cout << 1 << endl;
			continue;
		}else
		for (int i = 3; i <= n/2; i+=2) {
			if (sosu[n - i] == false&&sosu[i]==false) {
				++answer;
			}
		}
		cout << answer << endl;
	}
	return 0;
}