#include <iostream>
using namespace std;

int main(void){
	int prime[5136];
	prime[1] = 2;
	prime[2] = 3;
	int ptr=3;
	for(int num=5; num<=50000; num++){
		bool f = false;
		for(int i=1; i<ptr; i++){
			if(prime[i]*prime[i] > num){
				break;
			}
			if(num%prime[i]==0) {
				f = true;
				break;
			}
		}
		if(!f) {
			prime[ptr++] = num;
		}
	}
	prime[ptr] = 50001;
	int n;
	while(cin >> n){
		if(!n) break;
		int count = 0;
		for(int i=0; prime[i] < n; i++){
			for(int j=i; prime[j]< n; j++){
				if(n== prime[i]+prime[j]) count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}