#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 prime[5200];

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);
	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;
		}
	}
	int n;
	while(cin >> n, n) {
		int count = 0;
		rep(i, pnt) {
			if(n < prime[i]) continue;
			rep2(j, i, pnt) {
				int pp = prime[i] + prime[j];
				if(n == pp) ++count;
				else if(n <= pp) break;
			}
		}
		cout << count << endl;
	}
	return 0;
}