#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define X first
#define Y second
using namespace std;

void era(bool *table){
	for(int i = 2; i <= 50000; i++){
		if(table[i]){
			for(int j = i*2; j <= 50000; j+=i){
				table[j] = false;
			}
		}
	}
}

int main(){
	bool table[50001];
	memset(table, true, sizeof(table));
	era(table);
	int n;
	while(cin >> n && n != 0){
		int count = 0;
		if(n%2){
			cout << 0 << endl;
			break;
		}
		for(int i = 1; i <= n; i++){
			for(int j = i; j <= n; j++){
				if(!table[i]||!table[j]) continue;
				if(i+j==n) count++;
				if(i+j>n) break;
			}
		}
		cout << count << endl;
	}
	return 0;
}