#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int a = 50000;
bool sosuu[50001] = {false};
int x;
int n;

int main(){
	x = floor(sqrt(a));
	for(long long int i = 2; i < x+1; i++){
		if(sosuu[i] == true){
			continue;
		}
		for(long long int j = 2*i; j < a+1; j = j+i){
			sosuu[j] = true;
		}
	}
	while(cin >> n){
		int ans = 0;
		if(n == 0) break;
		if(n % 2 != 0){
			if(sosuu[n-2] == false) cout << "1" << endl;
			else cout << "0" << endl;
			continue;
		}
		for(int i = 2; i < n; i++){
			if(i > n-i) break;
			if(sosuu[i] == false && sosuu[n-i] == false) ans++;
		}
		cout << ans << endl;
	}
}