#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//エラトステネスの篩
const int N = 50009;
vector<bool> p2(N, true);
void Eratosthenes() {
	p2[0] = false;
	p2[1] = false;
	for (int i = 0; i < N; ++i)if (p2[i])
		for (int j = i * 2; j < N; j += i)p2[j] = false;
}

int main() {
	Eratosthenes();
	vector<int> p;
	rep(i, N) {
		if (p2[i])p.pb(i);
	}

	while (true) {
		int n; scanf("%d", &n);
		if (n == 0)break;

		int ans = 0;
		for (auto m : p) {
			if (m > n / 2)break;
			if (p2[n - m]) {
				ans++;
			}
		}
		printf("%d\n", ans);
	}
}
