#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<bool> is_prime(50000, true);
    vector<int> prime;
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<is_prime.size(); ++i) {
        if(is_prime[i]) {
            prime.push_back(i);
            for(int j=i+i; j<is_prime.size(); j+=i) {
                is_prime[j] = false;
            }
        }
    }
    vector<int> res(50001);
    for(int i=0; i<prime.size(); ++i) {
        for(int j=0; j<=i; ++j) {
            if(prime[i] + prime[j] > 50000) {
                break;
            }
            res[prime[i] + prime[j]] += 1;
        }
    }
    int n;
    while(cin >> n, n) {
        cout << res[n] << endl;
    }
}
