#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#define MAX_N 50001
using namespace std;
bool prime[MAX_N];

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

void init() {
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = false;
    for(int r = 2; r * r <= MAX_N; r++) {
        if(isPrime(r)) {
            for(int c = r * 2; c <= MAX_N; c += r) prime[c] = false;
        }
    }
}

int main(void) {
    init();
    int num;
    map<int, int> m;
    while(cin >> num, num != 0) {
        int cnt = 0;
        for(int r = 2; r < num; r++) {
            if(m.find(r) != m.end()) continue;
            if(prime[r] && isPrime(num - r)){ cnt++; m.insert(make_pair(num-r, r)); }
        }
        cout << cnt << endl;
    }
    return(0);
}