#include<iostream>
#include<cmath>
using namespace std;

bool judgePrimeNumber( int a )
{
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}

int main()
{
    int n;

    while( cin >> n )
    {
        if( n == 0 )
            break;

        int cnt = 0;
        for( int i = 2; i <= n / 2; i++ )
            if( judgePrimeNumber(i) && judgePrimeNumber(n-i) )
                cnt++;
        cout << cnt << endl;
    }
    return 0;
}

