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

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

    //50000以下の素数を配列に格納
    for( int i = x; i >= 2; 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;
        int sum = 0;
        for( int i = 0; i < pn.size(); i++ )
        {
            for( int j = i; j < pn.size(); j++ )
            {
                if( pn[i] + pn[j] == n )
                    sum++;
            }
        }
        cout << sum << endl;
    }

    return 0;
}
