#include <iostream>
#include <cmath>
using namespace std;
int dummy_prime(int n,int i){return i>1 ? n%i ? dummy_prime(n,i-1) : 0 : 1;}
int isprime(int n){return n>1 ? dummy_prime(n,sqrt(n)) : 0;}
int main()
{
int n,result;
while(cin >> n && n){
result=0;
for(int i=2;i<=n-i;i++)result+=(isprime(i)+isprime(n-i))/2;
cout<<result<<endl;
}
}