#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool is_prime(int number){
	for(int i = 2; i<=sqrt(number); i++){
		if(number % i == 0){
			return false;
		}
	}
	return true;
}

vector<int> filter(int n){
	vector<int> prime(1,2);
	for(int i = 3; i <= n; i++){
		if(is_prime(i)){
			prime.push_back(i);
		}
	}
	return prime;
}

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;
		int res = 0;
		vector<int> prime = filter(n);
		for(int i = 0; i < prime.size(); i++){
			for(int j = i; j < prime.size(); j++){
				int sum = prime[i]+prime[j];
				if(sum > n) break;
				if(sum == n) res++;
			}
		}
		cout << res << endl;
	}
	return 0;
}