#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
vector<int>prime;

int main(){
	for(int i=2;i<=100000;i++){
		bool f=1;
		for(int j=2;j*j<=i;j++)if(i%j==0)f=0;
		if(f)prime.push_back(i);
	}
	int n;
	while(cin>>n,n){
	int cnt=0;
	for(int i=0;;i++){
		if(prime[i]>n)break;
		for(int j=0;;j++){
			if(i>j)continue;
			if(prime[i]+prime[j]>n)break;
			if(prime[i]+prime[j]==n)cnt++;
		}
	}
	cout<<cnt<<endl;
	}
	return 0;
}