#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
bool prime(int n);

int main() {
    vector<int> array;
    int n;

    array.push_back(2);
    for (int i = 3; i < 50000; i+=2) {
        if (prime(i)) array.push_back(i);
    }//?´???°?????§?????????

    int count;
    while (cin >> n && n) {
        count = 0;
        for (int i = 0; 2 * array.at(i) <= n; i++) {
            if (find(array.begin(), array.end(), n - array.at(i)) != array.end()) {
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

bool prime(int n) {
    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}