#include <iostream>
using namespace std;

bool p[50001];

void prime()
{
	
	for (int i = 0; i < 50001; i++){
		p[i] = false;
	}
	
	p[2] = p[3] = p[5] = p[7] = true;
	
	for (int i = 2; i < 50001; i++){
		if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0){
			p[i] = true;
		}
	}
	
	/*for (int i = 0; i < 120; i++){
		if (p[i]) cout << i << endl;
	}*/
}

int main()
{
	int n;
	
	prime();
	
	while (cin >> n, n){
		int c = 0;
		if (n % 2 == 0){
			for (int i = 1; i <= n / 2; i++){
				for (int j = n - i; 0 <= j; j--){
					if (p[i] && p[j] && (i + j) == n){
						c++;
					}
				}
			}
		}
		cout << c << endl;
	}
	
	return (0);
}