#include <iostream>
using namespace std;
#define MAX 50100

bool isPrime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

int main(void){
    int d[MAX] = {0};
    for(int i = 2; i < MAX; i++) d[i] = isPrime(i);

    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        
        int c = 0;
        for(int i = 1; i <= n / 2; i++){
            if(d[i] == 1 && d[n - i] == 1) c++;
        }
        cout << c << endl;
    }
}
