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


int main()
{
    int x = 50000;
    int pn[50001];

    for( int i = 0; i < 50001; i++ )
        pn[i] = 0;

    //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[i] = i;
    }

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

        int cnt = 0;

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