#include<iostream>
using namespace std;

bool prime(int a, int b) {
	if (a == 3) {
		for (int d = 3;; d+=2) {
			if (b%d == 0)return false;
			if ((d + 1)*(d + 1) > b)return true;
		}
	}
	int c = 3;
	for (;; c+=2) {
		if (a%c == 0 || b%c == 0)return false;
		if ((c + 1)*(c + 1) > a)break;
	}
	for (int d = c;; d+=2) {
		if (b%d == 0)return false;
		if ((d + 1)*(d + 1) > b)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, a - b)) { s++;  }
			}
		}
		else {
			if (prime(2, a - 2))s++;
		}
		cout << s << endl;
	}
}