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

bool isprime(int n)
{
    for(int i=2,len=sqrt(n);i <= len;++i) if (!(n%i)) return false;
    return true;
}

int main()
{
    bool primes[50000]={false};
    primes[0] = true;
    for(int i=2;i <= 50000/2;++i) {
        if (primes[i-1]) continue;
        for(int j=i*2;j <= 50000;j+=i) {
            primes[j-1] = true;
        }
    }
    vector<int> prime;
    for(int i=0;i < 50000;++i) if (!primes[i]) prime.push_back(i+1);

    int n;
    while (cin >> n && n) {
        int cnt = 0;
        bool check[50000] = {false};
        for(int i=0,len=prime.size();i < len;++i) {
            if (n-1 <= prime[i]) break;
            if (n-prime[i] != prime[i] && check[n-prime[i]-1]) break;
            if (isprime(n-prime[i])) {
                ++cnt;
                check[prime[i]-1] = true;
            }
        }
        printf("%d\n", cnt);
    }

    return 0;
}