#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int MAX_N = 50000;
vector<int> prime;
int cnt[MAX_N + 10] = {};
bool is_prime[MAX_N + 1];

void sieve(int n) {
    for (int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        prime.push_back(i);
        for (ll j = i * i; j <= n; j += i) is_prime[j] = false;
    }
}

int main() {
    sieve(MAX_N);

    int sz = prime.size();
    for (int i = 0; i < sz; i++)
        for (int j = i; prime[i] + prime[j] <= MAX_N; j++)
            cnt[prime[i] + prime[j]]++;

    int n;
    while (scanf("%d", &n), n)
        cout << cnt[n] << endl;

    return 0;
}
