#include<iostream>
#include<vector>
#include<string>
using namespace std;

bool prime(int a) {
	for (int b = 3;; b += 2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b + 1) > a)return true;
	}
}
int main() {
	int a;
	while (cin >> a, a) {
		int s = 0;
		if (a % 2 == 0) {
			for (int b = 3; b <= a / 2; b += 2) {
				if (prime(b) && prime(a - b)) { s++;  }
			}
		}
		else {
			if (prime(a - 2))s++;
		}
		cout << s << endl;
	}
}