#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	bool p[33000]={false};
	bool f = false;
	
	for(int i = 3; i < 32790; i+=2){
		f = false;
		for(int j = 2; j * j <= i; j++){
			if(i % j == 0){
				f = true;
				break;
			}
		}
		if(f == false){
			p[i] = true;
		}
	}
	p[2] = true;
	
	//素数作り
	
	int n;
	while(scanf("%d",&n),n){
		int cnt = 0;
		bool check[33000] = {false};
		for(int i = 1; i < 32768; i++){
			if(p[i] == false || check[i] == true)continue;
			for(int j = i ; j < 32768; j++){
				if(p[j] == false || check[j] == true)continue;
				if(i + j == n){
					cnt++;
					//printf("d:%d %d\n",i,j);
					check[i] = true;
					check[j] = true;
					break;
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}