#include<iostream>

const int MAX = 5133;
using namespace std;

int ps[MAX];

bool primesearch(int key){
	int l = 0;
	int r = MAX;
	int m = 0;

	while( 1 ){
		if( r <= l ) break;
		if( m == (l + r) / 2 ) return false;
		else m = (l + r) / 2;

		if( ps[m] > key ) r = m;
		if( ps[m] == key ) return true;
		if( ps[m] < key ) l = m;
	}
	return false;
}

int main(void){
	int i = 3;
	int m = 0;

	ps[m++] = 2;
	while( m < MAX ){
		bool Skip = false;
		for(int j = 0; j < m; j++){
			if( i % ps[j] == 0 ){
				Skip = true;
				break;
			}
		}
		if( !Skip ) ps[m++] = i;
		i++;
	}

	while( 1 ){
		int n;
		int cnt = 0;
		
		cin >> n;
		if( n % 2 != 0 ){
			cout << 0 << endl;
			continue;
		}
		if( n == 0 ) break;

		for(int i = 2; i <= n / 2; i++){
			bool Found1 = false, Found2 = false;
			if( primesearch(i) && primesearch(n - i) ) cnt++;
		}

		cout << cnt << endl;

	}
	return 0;
}