#include <iostream>
#include <algorithm>
using namespace std;

int n;
int p[100000];

int main()
{
	int t = 0;

	for (int i = 3; i < 1000000; i += 2) {
		bool f = 1;
		for (int j = 3; j * j <= i; j++) {
			if (i % j == 0) {
				f = 0;
				break;
			}
		}

		if (f) {
			p[t] = i;
			t++;
		}
	}

	cin >> n;

	while (n) {
		int m = 0, i = 0;

		while (p[i] * 2 <= n) {
			if (binary_search(p, p + t, n - p[i]))
				m++;

			i++;
		}

		cout << m << endl;

		cin >> n;
	}

	return 0;
}

