#include<iostream>
#include<math.h>
using namespace std;
int p[20000];

void primefinder(int a){
	p[0] = 2;
	int k, l = 0;
	for (int i = 3; i <= a; i++){
		k = (int)sqrt(i);
		for (int j = 2; j <= k + 1; j++){
			if (j == k + 1){ p[++l] = i;}
			else if (i%j == 0)break;
		}
	}
}

int main(){
	int n, q, count;
	primefinder(50000);
	while ((cin >> n), n){
		count = 0;
		for (int i = 0; p[i] <= n / 2; i++){
			q = n - p[i]; if (q <= 1)continue;
			for (int j = 2; j <= (int)sqrt(q)+1; j++){
				if (j == (int)sqrt(q) + 1)count++;
				else if (q%j == 0)break;
			}
		}
		cout << count << endl;

	}
}