#include<cstdio>

const int N = 131072;
int prime[N] = {0},num_prime = 0;
int isNotPrime[N] = {1, 1};

int main()
{
    int n;
    for(long i=2; i<(2<<17); i++)
    {
        if(!isNotPrime[i])
            prime[num_prime++]=i;
        for(long j = 0 ; j < num_prime && i * prime[j] <  N ; j ++)
        {
            isNotPrime[i * prime[j]] = 1;
            if( !(i % prime[j] ) )
                break;
        }
    }
    while(~scanf("%d",&n),n)
    {
        int cnt = 0;
        for(int i=0; prime[i]<n; i++)
            for(int j=i; prime[j]<n; j++)
                if(prime[i] + prime[j] == n)
                    cnt++;
        printf("%d\n",cnt);
    }
    return 0;
}