#include <iostream>
#include <vector>

using namespace std;

typedef vector<int>::iterator ITE;

bool isprime(int n) {
	for (int i = 2; i * i <= n; i++)
		if (n % i == 0)
			return false;
	return n != 1;
}

int main() {
	int n;
	vector<int> v;
	for (int i = 2; i < 50000; i++)
		if (isprime(i))
			v.push_back(i);

	while (cin >> n && n) {
		int ans = 0;
		for (ITE i = v.begin(); i != v.end() && *i <= n; i++)
			for (ITE j = i; j != v.end() && *i <= n; j++)
				if (*i + *j == n)
					ans++;
		cout << ans << endl;
	}


	return 0;
}