#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,count=0;
	int b[1000];
	int i=3;
	while(true){
		bool t=false;
		for(int j=2;j*j<i+1;j++){
			if(i%j==0)
				t=true;
		}
		if(t==false){
			b[count]=i;
			count++;
		}
		if(count==999)
			break;
		i++;
	}
	while(true){
		count=0;
		cin>>n;
		if(n==0)
			break;
		if(n%2==1){
			int i=0;
			while(true){
				if(b[i]>n)
					break;
				if(b[i]==n-2)
					count=1;
				i++;
			}
		}
		else{
		int i=0;
		while(true){
			if(b[i]>n/2)
				break;
			for(int j=0;j<n;j++){
				if(b[i]+b[j]==n){
					count++;
				}
			}
			i++;
		}
		}
		cout<<count<<endl;
	}
	return 0;
}