#include<stdio.h>
int isPrime(int n){
	int i;
	if(n<=1 || n!=2&&n%2==0)return 0;
	for(i=3;i*i<=n;i+=2){
		if(n%i==0)return 0;
	}
	return 1;
}
int main(){
	int n,i,ans;
	while(scanf("%d",&n),n){
		ans=0;
		for(i=2;i*2<=n;i++){
			if(isPrime(i) && isPrime(n-i))ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}