#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int p[50000 + 1];
    rep(i, 50000 + 1) p[i] = 1;
    p[0] = 0, p[1] = 0;
    for (int i = 2; i <= (int)sqrt(50000); i++)
    {
        if (p[i] == 1)
        {
            for (int j = 2; i * j <= 50000; j++)
            {
                p[i * j] = 0;
            }
        }
    }

    vector<int> p_num;
    rep(i, 50000 + 1)
    {
        if (p[i] == 1)
        {
            p_num.push_back(i);
        }
    }
    int s = p_num.size();
    int dp[50000 + 1] = {};

    rep(i, s)
    {
        for (int j = i; j < s; j++)
        {
            if (p_num[i] + p_num[j] <= 50000)
                dp[p_num[i] + p_num[j]]++;
        }
    }

    int n;
    while (cin >> n, n)
    {
        OP(dp[n]);
    }

    return 0;
}
