#include<stdio.h>
#define MAX 10000
int n;
int primes[MAX];
int isPrime(int m){
	int i;
	if(m<=1 || m!=2&&m%2==0)return 0;
	for(i=3;i*i<=m;i+=2){
		if(m%i==0)return 0;
	}
	return 1;
}

int main(){
	int n,i,ans;
	while(scanf("%d",&n)==1&&n){
		ans=0;
		for(i=0;i*2<=n;i++){
			if(isPrime(i) && isPrime(n-i))ans++;
		}
		printf("%d\n",ans);
	}
}