#include <iostream>

using namespace std;

int main() {

    bool P[50001];
    fill(P, P + 50001, true);
    P[0] = P[1] = false;

    for (int i = 2; i * i <= 50000; i++) {
        if (P[i]) {
            for (int j = i * 2; j <= 50000; j += i) {
                P[j] = false;
            }
        }
    }

    int n;
    while (cin >> n) {
        if (n == 0) break;
        int ans = 0;
        for (int i = 2; i <= n / 2; i++) {
            if (P[i] && P[n - i]) ans++;
        }
        cout << ans << endl;
    }
}

