#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(7);

    bool sieve[100100];
    for (int i = 0; i < 100100; ++i)
        sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for (int i = 2; i * i < 100100; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; j * i < 100100; ++j)
                sieve[i * j] = false;
        }
    }

    vector<int> primes;
    set<int> st;
    for (int i = 0; i < 100100; ++i)
    {
        if (sieve[i])
        {
            primes.push_back(i);
            st.insert(i);
        }
    }

    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        int ans = 0;
        for (int i = 0; primes.size(); ++i)
        {
            if (n / 2 < primes[i])
                break;
            if (st.find(n - primes[i]) != st.end())
                ans++;
        }
        cout << ans << endl;
    }
    return 0;
}
