#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;

vector<int> sieve(int n) {
	vector<int> res(1, 2);
	vector<bool> prime(n, true);
	for(int i = 3; i < n; i += 2) {
		if(prime[i]) {
			res.push_back(i);
			for(int j = i * 3; j < n; j += i * 2)
				prime[j] = false;
		}
	}

	return res;
}

int main() {
	const int MAX = 50000;
	vector<int> prime = sieve(MAX), cnt(MAX + 1, 0);

	for(int i = 0; i < prime.size(); ++i) {
		for(int j = i; j < prime.size(); ++j) {
			int tmp = prime[i] + prime[j];
			if(tmp > MAX)
				break;

			++cnt[tmp];
		}
	}

	for(int n; scanf("%d", &n), n;)
		printf("%d\n", cnt[n]);

	return EXIT_SUCCESS;
}