#include <iostream>
#include <cmath>
using namespace std;

int prime[6500];

int main(){
    int a,b = 1,count;
    bool f = true;
    prime[0] = 2;
    for(int i = 3;i <= 50000;++i){
        for(int j = 2;j <= sqrt(i);++j){
            if(i % j == 0) {
            	f = false;
            	break;
            }
        }
        if(f) {
        	prime[b] = i;
        	++b;
        }
        f = true;
    }
    while(cin >> a,a){
        count = 0;
        if(a % 2 == 0){
            for(int i = 0;i < 5133;++i){
            	if(prime[i] > a) break;
            	for(int j = i;j < 5133;++j){
            		if(prime[i] + prime[j] == a) ++count;
            		else if(prime[i] + prime[j] > a) break;
            	}
            }
        }
        cout << count << endl;
    }
    return 0;
}