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

bool ip[50001];
vector<int> vec;

int main() {

    for(int i=0;i<50001;i++){
        ip[i] = true;
    }

    ip[0] = ip[1] = false;

    for(int i=2;i<=50001;i++){
        if(ip[i]){
            vec.push_back(i);
            for(int j = 2*i;j<=50001;j+=i){
                ip[j] = false;
            }
        }
    }

    int s = vec.size();

    while(1){
        int n;

        cin >> n;

        if(n==0) break;

        int ans=0;

        for(int i=0;vec[i]<=n && i<s;i++){
            for(int j=i;vec[j]<=n && j<s;j++){
                if(vec[i]+vec[j] == n){
                   ans++;
                }
            }
        }

        cout << ans << endl;

    }

    return 0;
}