#include <iostream>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)

char primes[1<<15];

void make_prime(){
	primes[0]=primes[1]=1;
	for(int i=4; i<(1<<15); i+=2)primes[i]=1;
	for(int i=3; i*i<=(1<<15); i+=2)if( !primes[i] )
		for(int j=i*3; j<(1<<15); j+=i)primes[j]=1;
}

int main(){
	int n;
	
	make_prime();
	
	while(cin>>n,n){
		int ans = 0;
		for(int i=n-2; i>=n/2; i--)if( !primes[i] && !primes[n-i] ){
			//printf("%d %d\n",i,n-i);
			ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}