#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define TRUE  1
#define FALSE 0

#define INPUT_MIN 4
#define INPUT_MAX 32768 /* 2^15 */

unsigned int calc(unsigned int p);
unsigned int Judge_Prime_number(unsigned int p);

void main(void){

	int lpcnt;
	int n;
	int ans;
	int p[1000];	

	n = 0;
	do{
		scanf("%d",&p[n]);
		n++;
	}while(p[n-1] != 0);

	ans = 0;
	for(lpcnt = 0;lpcnt < (n - 1);lpcnt++){
		ans = calc(p[lpcnt]);
		if(ans == 0){
			printf("err!\n");
		}
		else{
			printf("%d\n",ans);
		}
	}

}

unsigned int calc(unsigned int p){

	unsigned int half_p;
	unsigned int cnt;
	unsigned int x;
	unsigned int judge_1;
	unsigned int judge_2;
	
	cnt = 0;

	/* ??\???????????? */
	if((p < INPUT_MIN) || (INPUT_MAX < p)){  /* 4??\????????´??°??? 2^15??°????????´??° */
		/* error */
	}
	else if(0 != (p % 2)){  /* ?\???°?????¨??? */
		/* error */
	}
	else{
		/* 2?????\????????????????????????????´???°??????????????? */
		cnt = 0;
		half_p = p / 2;
		for(x = 2; x <= half_p;x++){
			judge_1 = Judge_Prime_number(x);
			judge_2 = Judge_Prime_number(p - x);
			if((judge_1 == TRUE) && (judge_2 == TRUE)){
				cnt++;
			}
		}
	}
	
	/* ?´???°?????°????????? */
	return(cnt);
}


unsigned int Judge_Prime_number(unsigned int p){

	unsigned int rtn;
	unsigned int cnt;
	unsigned int lpcnt;

	if(p == 2){
		rtn = TRUE;
	}
	else{
		cnt = 0;
		for(lpcnt = 1;lpcnt <= p;lpcnt++){
			if(p % lpcnt == 0){
				cnt++;
			}
		}
		if(cnt == 2){
			rtn = TRUE;
		}
		else{
			rtn = FALSE;
		}
	}

	return(rtn);
}