#include <bits/stdc++.h>
using namespace std;

int main() {
    int N = 50000;
    vector<int> primes;

    for (int j=2; j<=N; j++) {
        bool is_prime = true;
        for (int prime : primes) {is_prime = is_prime && (j % prime != 0);}
        if(!is_prime) continue;
        primes.push_back(j);
    }

    while(1){
        int n;
        cin >> n;
        if (n == 0) break;
        int res = 0;
        if(n % 2 == 0){
            for(int j=1;j<primes.size();j++){
                for(int k=j;k<primes.size();k++){
                    if (primes[j]+primes[k] == n) res++;
                }
            }
        }else {
            for(int j=1;j<primes.size();j++){
                if(primes[j] == n-2) res++;
            }
        }
        cout << res << endl;
    }
}
