#include <iostream>
#include <vector>
const int MAX = 50001;
using namespace std;

bool p[MAX];
vector<int> p_;

void f(){
    for(int i=0 ; i<MAX ; i++){
        p[i] = (i<=1)? false : true ;
    }
    for(int i=2 ; i*i<=MAX+1 ; i++){
        if( p[i] ){
            for(int j=i*2 ; j<MAX ; j+=i){
                p[j] = false;
            }
        }
    }
	for(int i=2 ; i<MAX ; ++i ){
		if( p[i] ) p_.push_back( i );
	}
}

int main(){
    int n;

    f();
    while( cin >> n , n ){
		int ans = 0;
		if( n < 4 || n%2 ){
			ans = 0;
		}else{
			for(int i=0 ; i<p_.size() && p_[i] <= n/2 ; ++i ){
				if( p[(n - p_[i])] && (n - p_[i]) >= p_[i] ){
					//cout << n << " = " << p_[i] << " + " << n - p_[i] << endl;
					ans++;
				}
			}
		}
		cout << ans << endl;
    }
}