#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define rep2(i, s, n) for(int i=s; i < n; ++i)
#define rep(i, n) rep2(i, 0, n)
#define MEMZERO(x) memset(x, 0, sizeof(x))
#define MEMSET(x, y) memset(x, y, sizeof(x))

using namespace std;

bool isPrime[50000];
int cPrime[50001];
int prime[5134];

void setPrime( bool *p, int n ) {
	p[0] = p[1] = false;
	int sq_n = sqrt((double)n);
	rep2(i, 2, sq_n) {
		if(!p[i]) continue;
		for(int j=i+i; j < n; j+=i) {
			p[j] = false;
		}
	}
}

int main( void )
{
	MEMZERO(prime);
	MEMZERO(cPrime);
	MEMSET(isPrime, true);
	setPrime(isPrime, 50000);
	int pnt = 1;
	prime[0] = 2;
	for(int i=3; i < 50000; i+=2) {
		if(isPrime[i]) {
			prime[pnt++] = i;
		}
	}
	rep(i, pnt) {
		rep2(j, prime[i], 50001-prime[i]) {
			if(isPrime[j]) ++cPrime[j+prime[i]];
		}
	}
	int n;
	while(cin >> n, n) {
		cout << cPrime[n] << endl;
	}
	return 0;
}