#include<iostream>
using namespace std;
bool  a[25001];
int b[25000];
int main() {
	int c = 0;
	fill(a, a + 25000, true);
	a[0] = false; a[1] = false;
	for (int i = 2; i <= 25000;) {
		if (a[i]) {
			int j = 2;
			while (i*j <= 25000) {
				a[i*j] = false;
				j++;
			}
			b[c] = i;
			c++;
		}
		if (i == 2) i++;
		else i += 2;
	}
	int n;
	while (cin >> n&&n != 0) {
		int sum = 0;
		int i = 0;
		while (b[i] <= n&&i != c) {
			if (a[n - b[i]]) {
				sum++;
			}
			i++;
		}
		cout << sum << endl;
	}
}