Problem:
Problem A:Goldbach's Conjecture

Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2.

This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair of prime numbers, if any, for a given even number. The problem here is to write a program that reports the number of all the pairs of prime numbers satisfying the condition in the conjecture for a given even number.

A sequence of even numbers is given as input. Corresponding to each number, the program should output the number of pairs mentioned above. Notice that we are intereseted in the number of essentially different pairs and therefore you should not count (p1, p2) and (p2, p1) separately as two different pairs.

Input

An integer is given in each input line. You may assume that each integer is even, and is greater than or equal to 4 and less than 215. The end of the input is indicated by a number 0.

Output

Each output line should contain an integer number. No other characters should appear in the output.

Sample Input

6
10
12
0

Output for the Sample Input

1
2
1

Solution in C++14 (judge verdict: Accepted)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;

namespace FastFourierTransform {
	using real=double;
 
	struct C {
	real x, y;
 
	C() : x(0), y(0) {}
 
	C(real x, real y) : x(x), y(y) {}
 
	inline C operator+(const C &c) const { return C(x + c.x, y + c.y); }
 
	inline C operator-(const C &c) const { return C(x - c.x, y - c.y); }
 
	inline C operator*(const C &c) const { return C(x * c.x - y * c.y, x * c.y + y * c.x); }
 
	inline C conj() const { return C(x, -y); }
	};
 
	const real PI = acosl(-1);
	int base = 1;
	vector< C > rts = {{0, 0},
					 {1, 0}};
	vector< int > rev = {0, 1};
 
 
	void ensure_base(int nbase) {
	if(nbase <= base) return;
	rev.resize(1 << nbase);
	rts.resize(1 << nbase);
	for(int i = 0; i < (1 << nbase); i++) {
		rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
	}
	while(base < nbase) {
		real angle = PI * 2.0 / (1 << (base + 1));
		for(int i = 1 << (base - 1); i < (1 << base); i++) {
		rts[i << 1] = rts[i];
		real angle_i = angle * (2 * i + 1 - (1 << base));
		rts[(i << 1) + 1] = C(cos(angle_i), sin(angle_i));
		}
		++base;
	}
	}
 
	void fft(vector< C > &a, int n) {
	assert((n & (n - 1)) == 0);
	int zeros = __builtin_ctz(n);
	ensure_base(zeros);
	int shift = base - zeros;
	for(int i = 0; i < n; i++) {
		if(i < (rev[i] >> shift)) {
		swap(a[i], a[rev[i] >> shift]);
		}
	}
	for(int k = 1; k < n; k <<= 1) {
		for(int i = 0; i < n; i += 2 * k) {
		for(int j = 0; j < k; j++) {
			C z = a[i + j + k] * rts[j + k];
			a[i + j + k] = a[i + j] - z;
			a[i + j] = a[i + j] + z;
		}
		}
	}
	}
 
	vector< int64_t > multiply(const vector< int > &a, const vector< int > &b) {
	int need = (int) a.size() + (int) b.size() - 1;
	int nbase = 1;
	while((1 << nbase) < need) nbase++;
	ensure_base(nbase);
	int sz = 1 << nbase;
	vector< C > fa(sz);
	for(int i = 0; i < sz; i++) {
		int x = (i < (int) a.size() ? a[i] : 0);
		int y = (i < (int) b.size() ? b[i] : 0);
		fa[i] = C(x, y);
	}
	fft(fa, sz);
	C r(0, -0.25 / (sz >> 1)), s(0, 1), t(0.5, 0);
	for(int i = 0; i <= (sz >> 1); i++) {
		int j = (sz - i) & (sz - 1);
		C z = (fa[j] * fa[j] - (fa[i] * fa[i]).conj()) * r;
		fa[j] = (fa[i] * fa[i] - (fa[j] * fa[j]).conj()) * r;
		fa[i] = z;
	}
	for(int i = 0; i < (sz >> 1); i++) {
		C A0 = (fa[i] + fa[i + (sz >> 1)]) * t;
		C A1 = (fa[i] - fa[i + (sz >> 1)]) * t * rts[(sz >> 1) + i];
		fa[i] = A0 + A1 * s;
	}
	fft(fa, sz >> 1);
	vector< int64_t > ret(need);
	for(int i = 0; i < need; i++) {
		ret[i] = llround(i & 1 ? fa[i >> 1].y : fa[i >> 1].x);
	}
	return ret;
	}
};


int main(){
	vector<int> isp((1<<15)+1,1);
	isp[0]=isp[1]=0;
	FOR(i,2,(1<<15)+1){
		if(isp[i]){
			for(int j=i*2;j<((1<<15)+1);j+=i){
				isp[j] = 0;
			}
		}
	}
	auto s = FastFourierTransform::multiply(isp, isp);
	int n;
	while(cin>>n,n){
		int x=0;
		if((n/2)*2==n)x=n/2;
		cout << int(s[n]+isp[x])/2 << endl;
	}
}