#include<iostream>
using namespace std;
bool isPrime(long n){
long i;
for(i=3;i*i<=n;i+=2){
if(n/i*i==n)return false;
}
return true;
}
int main(){
long i,n,s;
while(cin>>n,n){
s=0;
if(n/2*2==n){
for(i=3;i*2<=n;i+=2)if(isPrime(i)&&isPrime(n-i))s++;
}else{
if(isPrime(n-2))s++;
}
cout<<s<<endl;
}
return 0;
}