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

int isPrime(int n){
	int sq = sqrt((double)n);
	if(n==1)return 0;
	if(n==2)return 1;
	for(int i=2;i<=sq;++i)
		if(n%i==0)return 0;
	return 1;
}

int main() {
	int n,cnt;
	
	while(cin>>n,n){
		cnt = 0;
		
		for(int i=1;i<=n/2;++i){
			if(i==2 || i%2)
			cnt += isPrime(i) && isPrime(n-i);
		}
		
		cout << cnt << endl;
	}
	return 0;
}