#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 50001;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> isPrime(MAX_N, 1), prime;
    isPrime[0] = isPrime[1] = 0;
    for(ll i = 2; i * i <= MAX_N; i++)
    {
        if(isPrime[i] == 0) continue;
        for(int j = 2 * i; j <= MAX_N; j += i) isPrime[j] = 0;
    }
    for(int i = 2; i < MAX_N; i++) if(isPrime[i]) prime.push_back(i);
    int n;
    while(cin >> n, n)
    {
        int ans = 0;
        for(int i = 0; i < prime.size(); i++)
        {
            int x = n - prime[i];
            if(x < prime[i]) break;
            if(isPrime[x]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


