#include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;

int n;

bool sosu(int x){
	for(int i=2;i*i<=x;i++){
		if(x%i==0) return false;
	}
	return x!=1;
}

int main(){
	while(1){
		int ans=0;
		cin>>n;
		if(!n) break;
		for(int i=2;i<=n;i++){
			if(sosu(n-i)&&sosu(i)){
				ans++;
			}
		}
		cout<<(ans-1)/2+1<<endl;
	}
}