#include<iostream>
using namespace std;

int main() {
	int prime[10001], p = 3, n;
	prime[1] = 2, prime[2] = 3;
	for (int i = 5; p < 10001; i++) {
		int f = 0;
		for (int j = 1; prime[j] * prime[j] <= i; j++) {
			if (i%prime[j] == 0) {
				f = 1; break;
			}
		}
		if (!f) prime[p++] = i;
	}
	
	while (cin >> n) {
		int ans=0	;
		if (n == 0)break;
		for (int i = 1; i < 1000; i++) {
			for (int j = 1; j < 1000; j++) {
				if (prime[i] + prime[j] == n) {
					ans++;
				}
			}
		}
		cout << ans << "\n";
	}
}