#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

/*テァツエツ?ヲツ閉ーテ・ツ按、テ・ツョツ?/
const int MAX = 1000100;
bool prime[MAX];

void sieve(){
    fill(prime, prime+MAX, true);
    prime[0] = prime[1] = false;

    for(int i=2; i*i < MAX; i++){
	        if(!prime[i]) continue;
	        for(int j=i*i; j < MAX; j += i) prime[j] = false;
	    }
}


int main(){
	sieve();
	int n;
	while(cin >> n, n){
		int ret = 0;
		for(int i=0; i< n; i++){
			for(int j=i; j < n; j++) if(prime[i] && prime[j] && i+j == n) ret++;
		}
		cout << ret << endl;
	}
}