#include<iostream>

bool sosuu[50001];

void init(){
	for (int i = 0; i < 50001; i++)sosuu[i] = true;

	sosuu[0] = sosuu[1] = false;
	
	for (int i = 2; i*i < 50001; i++){
		if (sosuu[i]){
			for (int j = i * 2; j < 50001; j += i)sosuu[j] = false;
		}
	}
}

int main(){

	init();

	int n;
	while (std::cin >> n, n){

		int cnt = 0;

		for (int i = 2; i <= n / 2; i++){
			if (sosuu[i] && sosuu[n - i])cnt++;
		}

		std::cout << cnt << std::endl;

	}

	return 0;
}