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

int main()
{
    int x = 50000;
    vector<int> pn;

    //50000以下の素数を配列に格納
    for( int i = 2; i <= x; i++ )
    {
        bool judge = true;
        for( int j = 2; j <= sqrt(i); j++ )
        {
            if( i % j == 0 )
            {
                judge = false;
                break;
            }
        }
        if( judge == true )
            pn.push_back(i);
    }

    //整数の入力
    int n;
    while( cin >> n )
    {
        if( n == 0 )
            break;

        if( n % 2 != 0 )
            cout << 0 << endl;
        else
        {
            //整数nに一番近い素数を見つけ、それ以下の素数の組み合わせを調べる
            int target = 0;
            while( n > pn[target] )
                target++;

            int sum = 0;
            for( int i = 0; i < target; i++ )
            {
                for( int j = i; j < target; j++ )
                {
                    if( pn[i] + pn[j] == n )
                        sum++;
                }
            }
            cout << sum << endl;
        }
    }
    return 0;
}
