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

deque<int> Era(int n) {
    deque<int> arr(n+1,1);
    deque<int> prime;
    arr[0]=0;
    arr[1]=1;
    for (int i=2;i*i<n;i++) {
        if (arr[i]==1) {
            for (int j=i*i;j<n;j+=i) {
                arr[j]=0;
            }
        }
    }
    for (int k=2;k<=n;k++) {
        if (arr[k]==1) {
            prime.emplace_back(k);
        }
    }
    return prime;
}


int main(void){
    std::deque<int> prime=Era(60000);
    int ans[50001]={0};
    int size=prime.size();
    for (int i=0;i<size;i++) {
        for (int j=i;j<size;j++) {
            if (prime[i]+prime[j]>50000) {
                continue;
            }
            ans[prime[i]+prime[j]]++;
        }
    }
    int n;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            cout<<ans[n]<<endl;
        }
    }
}

