#include <iostream>
#include <vector>

using namespace std;

bool table[50000];
vector<int> prime;

int main() {
    for (int i = 2; i < 50000; i++) {
        if (table[i] == false) {
            prime.push_back(i);
            for (int j = i; j < 50000; j += i) {
                table[j] = true;
            }
        }
    }
    int n, size = prime.size();
    while (cin >> n && n != 0) {
        int ans = 0;
        for (int i = 0; i < size; i++) {
            if (prime[i] > n) {
                break;
            }
            for (int j = i; j < size; j++) {
                if (prime[i] + prime[j] > n) {
                    break;
                }
                if (prime[i] + prime[j] == n) {
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}