#include <iostream>
using namespace std;
#define n_size 50001

int main(){
    bool isPrime[n_size];
    isPrime[0] = false;
    isPrime[1] = false;

    for (unsigned i = 2; i < n_size; i++)
        isPrime[i] = true;

    for (unsigned i = 2; i * i < n_size; i++){
        if (isPrime[i]){
            for (unsigned j = (i * i); j < n_size; j += i)
                isPrime[j] = false;
        }
    }

    unsigned n;
    while(cin >> n && n!=0){
        unsigned cnt = 0;
        for(unsigned i=n-1;i>=n-i;i--){
            if(n%2!=0)
                break;
            if(isPrime[i] && isPrime[n-i])
                cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}
