#include<iostream>
using namespace std;
bool f(int a)
{
    if(a<2)return 0;
    for(int i=2;i*i<=a;i++)if(a%i<1)return 0;
    return 1;
}
int n;
main()
{
    while(cin>>n,n)
    {
        int c=0;
        for(int i=2;i+2<=n;i++)if(f(i)&&f(n-i))c++;
        cout<<c<<endl;
    }
}
